openmolecules.org

 
Home » DataWarrior » Functionality » Batch convert .csv to .DWAR
Re: Batch convert .csv to .DWAR [message #690 is a reply to message #684] Thu, 24 October 2019 22:08 Go to previous message
thomas is currently offline  thomas
Messages: 715
Registered: June 2014
Senior Member
you might use a DataWarrior macro to open the csv-file, append the template, save the file and quit DataWarrior (as shown below). Then use a Linux loop to mv one file after another into another working directory, apply the macro and rename and move the saved file back. Assuming, your csv files are in /home/thomas/csv and we use a working directory /home/thomas/test that contains the template t.dwat and convert.dwam, then it would look like this:

cd /home/thomas/csv
for FILE in *.csv ; do (mv "$FILE" ../test/t.csv; /opt/datawarrior/datawarrior ../test/convert.dwam; mv ../test/t.dwar "$FILE".dwar); done


this goes into the convert.dwam:

<macro name="convert">
<task name="openFile">
fileName=/home/thomas/test/t.csv
</task>
<task name="openAndApplyTemplate">
fileName=/home/thomas/test/t.dwat
</task>
<task name="saveFileAs">
fileName=/home/thomas/test/t.dwar
</task>
<task name="exitProgram">
saveChanges=yes
</task>
</macro>
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Change 2D Axes Range
Next Topic: Structure No Column
Goto Forum:
  


Current Time: Fri Nov 22 09:02:38 CET 2024

Total time taken to generate the page: 0.03961 seconds