LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Text File.vi Output file all but first line start with tab

Solved!
Go to solution
The attached PNG shows the code used to build up concatenated strings into a string array for the first four lines, thence to a string Array, to Spreadsheet String.vi and, finally, the use of Write to Text File.vi The lower right corner shows the result loaded into a spreadsheet. Note the 3 blank entries marked by a filled red rectangle. Examination of hidden characters shows there is a tab at the beginning of lines 2, 3 and 4. There is no tab shown in the code. How do those tabs get there? How do I stop them? I have tried with the option "Convert EOL" both on and off with no difference. The Help states that an OS-dependent EOL character is appended to each line. I can't imagine the Windows EOL character includes a tab.
0 Kudos
Message 1 of 4
(4,089 Views)
Solution
Accepted by topic author wildcatherder

The Tabs are coming from the Array to Spreadsheet String Function.  You are building a Spreadsheet string, complete with Tabs and CR.  Just drop a Concatenate Strings in its place and it will work.

 

I would bag all of the tab constants and CR.  Build an 2D string array with just the values (no tabs, no CRs), pass this into the Array to SS function.

0 Kudos
Message 2 of 4
(4,081 Views)

So, I replaced both the Build Array.vi and the Array to Spreadsheet String.vi with a Concatenate Strings.vi and wired the resultant string into the Write to TextFile.vi and got the desired result.

 

I am still puzzled as to why those additional tabs were added by Array to Spreadsheet String.  I'm holding in my hand a printout of an old LabVIEW 8 program with that construction, which is known to work properly.

 

Anyway, thanks for the quick response which gets me rolling again.

0 Kudos
Message 3 of 4
(4,073 Views)

wildcatherder wrote:

I am still puzzled as to why those additional tabs were added by Array to Spreadsheet String.  I'm holding in my hand a printout of an old LabVIEW 8 program with that construction, which is known to work properly.


Makes complete sense when you look at your code.  You build a string, including an end-of-line character, and put that string into an array.  Then, when you run it through Array to Spreadsheet String, it puts a tab after every array element, and new line at the end of each row in the array.  The first element of your array contains a new line but Array to Spreadsheet String doesn't know about it; it still inserts a tab between that array element and the next one, giving you the tabs.

0 Kudos
Message 4 of 4
(4,059 Views)