Jump to content

How do I convert a multiline string to Array


RaviPaike

Recommended Posts

I am reading a csv file using read file Vi but the problem i am facing is the out put of that vi is a multinline string but i don't know how to convert this multiline string in to array. 

have anybody of you tried this 

Thanks

3690[/snapback]

The "oglib_string" library which you can obtain using OpenG Commander has a VI called "Multiline string to Array".

Link to comment
I don't mean to correct you Alex but I think you would need to specify a comma for a delimeter, no?

3730[/snapback]

No, because because the delimiter is an EOL character (each line in the string becomes and array element). However, that code has a couple small issues:

1) the LabVIEW "End of Line Constant" changes depending on platform (Windows EOL = CRLF, Mac EOL = CR, Linux EOL = LF), which may not give consistent results for the same input string.

2) the code does not handle strings with mixed EOL characters

While the OpenG version of "Multiline String to Array" does not exactly keep it simple (if you feel the need to look at the code), it does handle any combination of mixed EOL characters. It does this by first replacing all instances of CRLF with LF and then replacing all instances of CR with LF and then using a LF delimiter to convert the string to an array.

hey Thanks Jim.

3696[/snapback]

You're welcome :)

Link to comment

Yes, I know I should have said: to avoid the need to install/download OpenG(1), and if you don't need/want OS independent code, and you're not interested in mixed EOL characters, and, and, and, ... but I thought I had covered that with "smooch" :)

1. although you should've done this as the first step after purchasing LV, IMHO.

P.S. Michael, I will always welcome corrections! That's how you learn! In this case however, the code was just using the tool with the EOL as delimter as a quick solution.

Link to comment
Yes, I know I should have said: to avoid the need to install/download OpenG(1), and if you don't need/want OS independent code, and you're not interested in mixed EOL characters, and, and, and, ... but I thought I had covered that with "smooch"  :)

1. although you should've done this as the first step after purchasing LV, IMHO.

P.S. Michael, I will always welcome corrections! That's how you learn! In this case however, the code was just using the tool with the EOL as delimter as a quick solution.

3753[/snapback]

Ok guys. I have an issue with this implementation with respect to showing new users how to do things. I now understand what you are trying to show Alex but the "proper" conversion of a CSV file to an array would go something like this:

post-2-1107408509.gif?width=400

Let's not forget that the original question was asking about a CSV (comma separated values) string.

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.