![]() ![]() (I've used it both under Ubuntu and Mac OSX 10.10.5 it also has Windows executable.) XMLSpearĪs mentioned, it is an XML editor, but it includes CSV-to-XML (and Excel-to-XML) "import" on its main menu: Then the needed text for xml is just wrapped around the values and the xml line is appended to the output file with echo.Ī fairly user-friendly (i.e., easy for numpties like me) solution to the CSV to XML conversion challenge is to use a nice cross-platform XML editor that has this feature built-in. ![]() So each column in the line is stored in an array. In other words the values between the commas. The columns in this example are name, age, country. The -a arry argument places each column of your file into an array (named arry). The -r argument to the read command tells it to treat any backslashes in your file as part of your data rather than as an escape for a following special character. This is standard for a CSV file, but it can be changed as needed to match the input file format. The IFS=$',' declares that the value of the field separator is a comma. The file is read line-by-line in the while loop. Take the file simple.csv: Jack,35,United StatesĮven if you have never coded before, I think this should be easy to use and modify. When you know the format of the csv file and the structure you need in the xml file, it's fairly straightforward to make a script that can handle the conversion.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |