|
|
|
Re: Batch convert .csv to .DWAR [message #684 is a reply to message #681] |
Wed, 23 October 2019 00:25 ![Go to previous message Go to previous message](/forum/theme/myThemeWithHFCSS/images/up.png) ![Go to next message Go to next message](/forum/theme/myThemeWithHFCSS/images/down.png) |
nbehrnd
Messages: 215 Registered: June 2019
|
Senior Member |
|
|
Assuming Thomas' script did the catenate the files, ensure that each of the columns
has a header; for example "structure, mass" as in the example.csv attached below.
(An extension .txt equally will be recognized sucessfully by DataWarrior. If working
in Linux, DataWarrior will trade well with the file regardless if the line ending
is encoded in dos, or unix convention, too.)
Then open either by shortcut Ctrl + O, or in the menue File -> Open the directory
and eventually the .csv in question. While reading the file, DataWarrior converts
automatically the structure string to populate an additional column.
![index.php?t=getfile&id=125&private=0](index.php?t=getfile&id=125&private=0)
Do not forget to explicitly instruct DataWarrior to save the read as .dwar.
-
Attachment: dw_import.png
(Size: 4.77KB, Downloaded 726 times)
-
Attachment: example.csv
(Size: 0.05KB, Downloaded 407 times)
-
Attachment: example.dwar
(Size: 1.37KB, Downloaded 405 times)
[Updated on: Wed, 23 October 2019 00:27] Report message to a moderator
|
|
|
Re: Batch convert .csv to .DWAR [message #690 is a reply to message #684] |
Thu, 24 October 2019 22:08 ![Go to previous message Go to previous message](/forum/theme/myThemeWithHFCSS/images/up.png) |
thomas
Messages: 693 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>
|
|
|