hello friends
i was trying to make a program for reading data from csv..
my data will be like LWP15452,145 i need to read LWP15452 and 145 seperate.. in present i can able to read the entire line ..
pls help
thanks
vipin
hello friends
i was trying to make a program for reading data from csv..
my data will be like LWP15452,145 i need to read LWP15452 and 145 seperate.. in present i can able to read the entire line ..
pls help
thanks
vipin
Hello,
is the number of characters always the same? If so, you can just use the built-in function SUB_STR(source_string , start, len) that return a substring of source_string starting from start character and takes up to len characters
An example would be:
Hello,is the number of characters always the same? If so, you can just use the built-in function SUB_STR(source_string , start, len) that return a substring of source_string starting from start character and takes up to len characters
An example would be:
hi...
thanks for that, but number of characters is not same in my case...
The standard way would be to use regular expression, but as far as I know there isn't support in Karel.
A workaround here would be to use some IF clauses and the built-in function STR_LEN to identify how your string is structured or maybe check where the ',' is, that depends on the format of your string.
Once you have to correct lengths you can use SUB_STR as I shown
Maybe use loops to read each character of the string until any ",' shows up then split the string.
Maybe use loops to read each character of the string until any ",' shows up then split the string.
How?? i have checked formatting string data, ::0::2 by using this i can able to separate string with quotes not with comma..........
This will probably do
first_part = ""
second_part = ""
change_part = FALSE
FOR i=1 TO STR_LEN(full_line) DO
current_character = SUB_STR(full_line, i, 1)
IF current_character <> ',' THEN
IF NOT change_part THEN
first_part = first_part + current_character
ELSE
second_part = second_part + current_character
ENDIF
ELSE
change_part = TRUE
ENDIF
ENDFOR
Display More
This will probably doCode Display Morefirst_part = "" second_part = "" change_part = FALSE FOR i=1 TO STR_LEN(full_line) DO current_character = SUB_STR(full_line, i, 1) IF current_character <> ',' THEN IF NOT change_part THEN first_part = first_part + current_character ELSE second_part = second_part + current_character ENDIF ELSE change_part = TRUE ENDIF ENDFOR
Hi..
great this is working.... thanks