LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

converting xml file to csv file

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.

 

0 Kudos
Message 1 of 11
(5,864 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(5,858 Views)

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

 

0 Kudos
Message 3 of 11
(5,844 Views)

i forgot to attach the csv file in the last post.

 

Here is the csv file.

0 Kudos
Message 4 of 11
(5,843 Views)

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(5,841 Views)

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.

0 Kudos
Message 6 of 11
(5,832 Views)

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.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 7 of 11
(5,820 Views)

Thanks aCe for the reply,

 

i will try as you have explained.

0 Kudos
Message 8 of 11
(5,814 Views)

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.

0 Kudos
Message 9 of 11
(5,807 Views)

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.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 10 of 11
(5,802 Views)