LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Breaking notepad to array

Solved!
Go to solution

I have a notepad in which there are 100s of line and each ending by  CR and LF character. I need to insert each record to an array. I tried but this is time cosuming

 

Text is like

 
$GPRMC,120442.000,A,1257.4713,N,07744.6606,E,0.00,84.48,211115,,,A*5E<CR><LF>
$GPRMC,120442.000,A,1457.4713,N,07744.6606,E,0.00,84.48,211115,,,A*58<CR><LF>
$GPRMC,120442.000,A,1457.4713,N,07744.6606,E,0.00,84.48,211115,,,A*58<CR><LF>
$GPRMC,120442.000,A,1457.4713,N,07744.6606,E,0.00,84.48,211115,,,A*58<CR><LF>
$GPRMC,120442.000,A,1257.4713,N,07744.6606,E,0.00,84.48,211115,,,A*5E<CR><LF>
$GPRMC,120442.000,A,1257.4713,N,07744.6606,E,0.00,84.48,211115,,,A*58<CR><LF>

 

Each row I need to insert to an array

 

Attached text file.

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 1 of 9
(4,133 Views)

Example_VI.png

Message 2 of 9
(4,121 Views)
Solution
Accepted by topic author Ranjeet_Singh

@Ranjeet_Singh wrote:

I need to insert each record to an array.

 


 

What is a "record"? If each line is a record, use "read from text file" and configure it to "read lines" (right-click...)

 

 

 

0 Kudos
Message 3 of 9
(4,098 Views)

I used string search, for loop to do this but this is rocking..Thanks

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 9
(4,077 Views)

With Blokks solution you'll even get the elements extracted.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 9
(4,056 Views)

@Yamaeda wrote:

With Blokks solution you'll even get the elements extracted.

/Y


Yes, but that wasn't the question. 😉

0 Kudos
Message 6 of 9
(4,047 Views)

@altenbach wrote:

@Yamaeda wrote:

With Blokks solution you'll even get the elements extracted.

/Y


Yes, but that wasn't the question. 😉


Well, we do not know what the OP wants to do with those "records". So I can just guess maybe he wants to do some operation on each and whole lines as strings. Otherwise if the OP needs to extract individual elements, he should go with my example, to get the 2D string. After that each columns as 1D string arrays can be indexed out, and transformed into numerical values when needed...

Message 7 of 9
(4,037 Views)

@Yamaeda wrote:

With Blokks solution you'll even get the elements extracted.

/Y


I need 1D not 2D array

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 8 of 9
(4,025 Views)

@Blokk wrote:

@altenbach wrote:

@Yamaeda wrote:

With Blokks solution you'll even get the elements extracted.

/Y


Yes, but that wasn't the question. 😉


Well, we do not know what the OP wants to do with those "records". So I can just guess maybe he wants to do some operation on each and whole lines as strings. Otherwise if the OP needs to extract individual elements, he should go with my example, to get the 2D string. After that each columns as 1D string arrays can be indexed out, and transformed into numerical values when needed...


We should focus on he original requirement of "Each row I need to insert to an array". A row is the atomic unit here. 

 

Sill, with a bit of a detour, "read delimited spreadsheet" could be used by selecting transpose, using a eol as delimiter, and getting the first row. Same difference. Still, my original solution is more direct and probably more efficient. Read delimited spreadsheed does a lot more work internally.

 

 

 

However, in this particular case, each line seems to contain an identical number of characters, allowing for the possibility to chop up the file by position without even looking at the content. That might be more efficient than having to search for EOL over and over. Worth considering but I have not tried. Probably not worth the effort for more typical file sizes.

0 Kudos
Message 9 of 9
(3,994 Views)