LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tab delimited spreadsheet also using new line

I'm writing a tab delimited spreadsheet and also reading it back elsewhere in the program. Some of the data has new lines in it. The read spreadsheet is treating the newline as a delimiter as well. Is there any way to stop this?
0 Kudos
Message 1 of 6
(1,818 Views)

Whenever you use the array to spreadsheet string function, it adds a newline as the ending character, you can remove this by using a trim whitespace after the array to spreadsheet string function.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 6
(1,805 Views)

A spreadsheet is a two-dimensional Data Structure, designed to be "human-readable", hence the data are represented by strings (typically encoding numeric data).  To define the "two dimensions", a character needs to be "reserved" for the "column separator", and a different character "reserved" for the row (or "line") separator.

 

The most "natural" way to separate "lines to text" (= "rows of a spreadsheet") is with the <EOL> (end-of-line) character(s), which can be <CR>, <CR><LF>, or <LF> (depending on various things, such as Windows, Mac, Linux, etc.).  The two most common column separators are <tab> (the LabVIEW and Excel default), and the comma (",") -- the latter type of file is sometimes called a "Comma-separated Values" file, and might be given the extension ".csv".  However, Microsoft has "hijacked" this extension in Windows by creating an Icon for this file type that looks very much like the icon for the Excel ".xls" and ".xlsx" file types, leading LabVIEW users asking "How can I read/write Excel files" and confusing "delimited Spreadsheets" (text files) and native Excel (.xlsx) files.

 

It sounds like you might have a system where <EOL> is, perhaps, <CR><LF>, and you have a file with "extra" <CR> or <LF> characters.  If so, your file has "bad characters" in the file that might confuse the Delimited Spreadsheet reader -- you can "fix this" by simply reading your file one (entire) line at a time, looking at the next character, and if it is another <CR> or <LF>, deciding if it is "real" (for example, a "blank line") or "garbage" (such as the sequence <CR><LF><LF>, which you can fix by discarding the "bad" character.

 

Bob Schor

0 Kudos
Message 3 of 6
(1,780 Views)

@Hepcat wrote:
I'm writing a tab delimited spreadsheet and also reading it back elsewhere in the program. Some of the data has new lines in it. The read spreadsheet is treating the newline as a delimiter as well. Is there any way to stop this?

Since you are writing the tab delimited spreadsheet, you have full control over the format. If you would attach some simplified code, we could probably tell you where the problem is without wildly guessing.

 

  • What is the datatype of the elements of your array (numeric, string, etc.)
  • If "string" are the strings clean or do they also have nonprintable characters? Make sure they don't contain any delimiters used for the spreadsheet IO (e.g.  tab, newline, etc.)
  • Are you writing the entire file at once or are you appending in sections? How?

Once we see a simplified version of your code (writing and reading sections), we can provide more feedback.

0 Kudos
Message 4 of 6
(1,760 Views)
I'm just going to open it as text and search for the tabs in a loop and output the array that way. Thanks everyone.
0 Kudos
Message 5 of 6
(1,731 Views)

@Hepcat wrote:
I'm just going to open it as text and search for the tabs in a loop and output the array that way. Thanks everyone.

So that probably means that you only have a 1D array.

 

If you use "spreadsheet string to array" and use a 1D array as type, the newlines are no longer special. No loop or searching needed.

 

altenbach_0-1661353823287.png

 

 

Message 6 of 6
(1,724 Views)