LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

transfer text file to different columns in spreadsheet

Hi, folks,

I am transferring a text file to spreadsheet.

The file has a lot of junk words has to be throw away, this part is easy, the challenge is to keep the file name as header and two columns of data, then append another file name/data to different columns.

 

I just get started to use Labview, quickly enough I have no problem to append data to the end of the spreadsheet (I save spreadsheet called test_output on desktop) but no success wahtsoever to write into different columns.

 

I attached my code and the text file.

Any help are greatly appreciated!!!

 

Ray

0 Kudos
Message 1 of 5
(3,437 Views)
Is that data file an input file or an output file to your program?
 
What do you mean by different columns?  First, technically you aren't creating a spreadsheet file with those functions.  You are creating a text file that can be formatted in a way to be more easily opened by a spreadsheet program.  I am a little confused as to whether you want to append the 3 files one write after the other which is what you are doing, because "different columns" implies something different.
 
Perhaps you can post a rough example of how you want the output file to look.
0 Kudos
Message 2 of 5
(3,421 Views)

Hi, Thanks for looking into my question, putty_text is the input text file. My code will produce a text file like the first attached below (called text_output),

What I hoped it to be is the second one (called text_expected_output).

You are right, my current output is not a spreadsheet, rather a text file which can be read by Excel, this's fine to me at this moment as long as data

can be appended to different column in one single file.  The for loop runs three time in the code and this is also only for the illustration purpose.

 

 

 

 

Download All
0 Kudos
Message 3 of 5
(3,396 Views)

It looks like your VI is only designed to run once on a single file.  I am not sure why the for loop has N=3.  Since you are looking to add a new file into adjacent columns, you won't be able to use the append to file, or write to the file at all within the loop.  That's because the file gets written to at the end thus making it longer.  You want your file to basically expand to the right where each line would have need data added to it before a linefeed character.

You will need to be able to select all 3 files in a loop and let the code process each one and create a string array.  On each iteration, you will need to append a 2-D array to another 2-D array using the build array function.  It may get tricky and you may need to use transpose array functions to make sure the final form of the array gets build the way you want.

Once the loops are done iterating, only then can you write your string array out to the file.

0 Kudos
Message 4 of 5
(3,384 Views)

Thanks for hint, my code runs successfully nowSmiley Very Happy, the tricky part is to use transpose array twice, one inside the loop before building array function, another outside the loop before writing to the file.

Why the for loop has N=3 is not my concern, it probably should be, cause I actually don’t know how to quit the for loop when searching the text file to the end. But setting N equal to a larger number seems just works fine.

0 Kudos
Message 5 of 5
(3,346 Views)