Jump to content

troubles with xml -> csv conversion


Recommended Posts

Hallo,

I'm an Italian Engineering student, working with LabVIEW for thesis work I'm facing big problems in the use of XML files. I have an application which generates XML files with clusters containing arrays and scalars according like in the example pasted below. My task is to read it and export the data in a human-friendly CSV document.

Since I don't know the actual content of the cluster, I need some kind of intelligent vi which goes through the XML file looking for arrays and other data structures in order to export them properly in the CSV format (columns with headers).

Thank you

<Cluster>

<Name></Name>

<NumElts>3</NumElts>

<Array>

<Name></Name>

<Dimsize>6</Dimsize>

<I32>

<Name></Name>

<Val>0</Val>

</I32>

<I32>

<Name></Name>

<Val>1</Val>

</I32>

<I32>

<Name></Name>

<Val>2</Val>

</I32>

<I32>

<Name></Name>

<Val>3</Val>

</I32>

<I32>

<Name></Name>

<Val>4</Val>

</I32>

<I32>

<Name></Name>

<Val>5</Val>

</I32>

</Array>

<DBL>

<Name></Name>

<Val>3.14159265358979</Val>

</DBL>

<String>

<Name></Name>

<Val>ciao</Val>

</String>

</Cluster>

Link to comment

Hello

Do all files have exactly the same structure and number of data?

Hallo,

I'm an Italian Engineering student, working with LabVIEW for thesis work I'm facing big problems in the use of XML files. I have an application which generates XML files with clusters containing arrays and scalars according like in the example pasted below. My task is to read it and export the data in a human-friendly CSV document.

Since I don't know the actual content of the cluster, I need some kind of intelligent vi which goes through the XML file looking for arrays and other data structures in order to export them properly in the CSV format (columns with headers).

Thank you

<Cluster>

<Name></Name>

<NumElts>3</NumElts>

<Array>

<Name></Name>

<Dimsize>6</Dimsize>

<I32>

<Name></Name>

<Val>0</Val>

</I32>

<I32>

<Name></Name>

<Val>1</Val>

</I32>

<I32>

<Name></Name>

<Val>2</Val>

</I32>

<I32>

<Name></Name>

<Val>3</Val>

</I32>

<I32>

<Name></Name>

<Val>4</Val>

</I32>

<I32>

<Name></Name>

<Val>5</Val>

</I32>

</Array>

<DBL>

<Name></Name>

<Val>3.14159265358979</Val>

</DBL>

<String>

<Name></Name>

<Val>ciao</Val>

</String>

</Cluster>

Link to comment

Hello

Do all files have exactly the same structure and number of data?

No, that's the problem, in other words I cannot use the unflatten function.

Clusters may contains one or more arrays of different sizes, scalars of different types...

Elements of the cluster are supposed to be its children, aren't they? Is it possible to access each of them from the children list of the cluster, see which is their type and implement different data extractor for 1D array, 2D array and scalars? Then write these data in a csv file should be the easier part.

I think it's gonna be a mess, but there should be some way,no?

I'm forwarding my vi draft with many comments and a couple of xml file samples.

Thank you very much

data structure.doc

XMLData_example1.xml

XMLData_example2.xml

read_array.vi

Link to comment

No, that's the problem, in other words I cannot use the unflatten function.

Clusters may contains one or more arrays of different sizes, scalars of different types...

Elements of the cluster are supposed to be its children, aren't they? Is it possible to access each of them from the children list of the cluster, see which is their type and implement different data extractor for 1D array, 2D array and scalars? Then write these data in a csv file should be the easier part.

I think it's gonna be a mess, but there should be some way,no?

I'm forwarding my vi draft with many comments and a couple of xml file samples.

Thank you very much

You could use search and split vi in String palette and Addition string functions and work on the string by using them. Write up the common cases of clusters as a start.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.