12-13-2013 01:14 AM
we are generating xml file from LabVIEW which we want to convert in csv format, i have gone through several post on this but none helped much, i am getting error even at first step when i am using read from xml nothing is coming in output , i saw one post on this, there it was mentioned some LabVIEW schema problem but we are generating this xml file from LabVIEW only.
below i am attaching the data we are having in xml file.
12-13-2013 01:39 AM - edited 12-13-2013 01:40 AM
Hi RC,
both XML and CSV are plain text files! In the easiest case you just rename your file from *.xml to *.csv... 😄
You should explain what kind of data structure you want to achieve by converting to CSV. How should the information present in the XML file be structured in the CSV file to be generated?
When the example file is generated by your LabVIEW program you should know the cluster typedef that is used to create the XML data. You need that typedef to read the XML information using LabVIEW!
12-13-2013 02:25 AM
Thanks GerdW for reply,
it was showing some error while posting xml file that's why i copied the content of xml into notepad and saved it as txt otherwise it's xml file only.
below i am attaching one csv file which tells us the type of data structure we want to achieve.
yes we know the cluster typedef which is creating xml data.
You need that typedef to read the XML information using LabVIEW!
By this line you mean that instead of reading xml file i should use this type def to convert xml data to csv
12-13-2013 02:26 AM
i forgot to attach the csv file in the last post.
Here is the csv file.
12-13-2013 02:32 AM
Hi RC,
there's a lot more information in the XML than what is stored in the CSV.
So it's your task to define which information is picked from XLM and where it is to be located in the CSV file! Once you have that definition set up it will be easy to write a conversion routine...
12-13-2013 02:42 AM
Hi GerdW,
but i am getting problem at first step only, i am not able to read the data from xml file, when i am trying to use read from xml file it is not showing anything in output.
i am attaching the snippet of vi where i am trying to read from the xml file, it is not showing any error but still nothing is coming in output.
12-13-2013 03:15 AM
The file is not written with XML headers, its just a cluster flattened in to XML and saved as a file. If you open up the read from XML (String) vi, you will understand why.
I would suggest that you read it in as a text file, unflatten it (provide the right data type, in this case parameters cluster) and you can then choose what you want to write to your CSV. This will give you a lot more control the information you want to save.
12-13-2013 03:48 AM
Thanks aCe for the reply,
i will try as you have explained.
12-13-2013 04:08 AM
Thankc aCe,
you were right it's just a cluster flattened to xml, now ia m able to read the file , one question i want to ask the data type that i need to give to unflatten is need to be the same the cluster with which i am making xml file , or we can simple give cluster constant i am asking this question becuase i am having some different programs in which clusters with which we are making xml file is not the same so i just want to know do we need to give the same cluster or is their anyway by which we dont need to change the datatype with every program, i just want to know if there is any approach.
12-13-2013 04:16 AM
The simple answer is no, the datatype has to match if you want to use those vi's.
If you want a more generic approach, you will need to parse the xml file to extract data, do a search and you can find many examples.