LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple text lines in spreadsheet

I have a a text file (tab delim) that contains text & numbers in it eg:
T800-12SC    0.003   10   0.125
T300-15XY     0.002   15   0.135
etc.
If I tried to read the row, the text field shows up as 0.
I found an example "Read Text Header from Spreadsheet File.vi) where you had to tell it your header size and then it reads it, only thing is that teh file reads the first row and rest of rows that contains text become 0!
 
I'm new to Labview & not too familiar with all the functionalities it has.
 
I'm attaching the two files that I found regarding this.
i would like also to write to the same file when I add new product line.
 
thanks in advance
0 Kudos
Message 1 of 7
(3,824 Views)
The problem with your approach is that your file does not contain a single header and then numbers in the rest of the rows and columns - every row has text. You need to read/write the entire file as text. The Read From Spreadsheet File and Write To Spreadsheet File functions contains instructions on the block diagram that explain how these fucntions can be modified. When you write your data, you will first have to convert all of the numbers to strings.
0 Kudos
Message 2 of 7
(3,818 Views)
If you are using Read from Spreadsheet File, and your text contains some non-numeric characters, it will show up as 0 because it is not a number.  In your example T800... is not a number, so it has to show up as 0.  If you want to see text and numbers then use Read Characters from File.  Then you must separate the fields by using Match Pattern, and use a space as the match character.  The "before" output will be field 1, or T800-12SC.  Repeat Match Pattern using the previous Match Pattern "after" output as the input to the second Match Pattern.  Again the "before" output will be field 2, or 0.003.  Repeat for entire line, or until Match Pattern returns -1 as the index output.  Then convert all number strings into numbers and put into array.  If using a loop, you can have the loop create the array by using enable indexing.  Just can't put the text field into the array of numbers, so you have to code for that.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 7
(3,812 Views)

Hiii, Dennis

                                 As you specify king shadi..... doesnt have the single header in the one line, so he cant do that  but I have a header in the first line only then what i should do?

Thanks,
Nishant
0 Kudos
Message 4 of 7
(3,793 Views)

Hi King,

      Scan From String might be a nice way to approach this.  You could simply read the entire txt file and convert it line by line (see example.)

... and, when it's time to append new records, use Format into string ( A... TS Smiley Wink )

 

When they give imbeciles handicap-parking, I won't have so far to walk!
Message 5 of 7
(3,785 Views)
Hi need help let say i have multi line text and i need to count how many lines in the text.
 
Example this is the text.
 
"REC UNREAD","+60126422014",,"08/05/13,14:37:40+32"
**AC ok**
SED001 TESTING 14:33 13/05/08
12.12 VOLT
DR1=OP,DR2=OP,MTD=OFF,RSP1=REP,RSP2=REP,RSP3=REP,SA1=REP,SA2=REP,SA3=REP,RAS1=REP,RAS2=REP,
 
some text many be more than 5 line.
 
Plz help.
0 Kudos
Message 6 of 7
(3,429 Views)
You can use the Search and Replace String function to count the number of line feeds in a text file.  See attached vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 7
(3,401 Views)