To Read an Array From CSV File in JBC
- priyankaJacob123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 1 month ago #18312
by priyankaJacob123
To Read an Array From CSV File in JBC was created by priyankaJacob123
Please find the requirement.
I am writing a test routine in JBC which needs to input an array from CSV file. Can I know the syntax to read from CSV file please.
Thanks in advance.
I am writing a test routine in JBC which needs to input an array from CSV file. Can I know the syntax to read from CSV file please.
Thanks in advance.
Please Log in or Create an account to join the conversation.
- jpb
- Offline
- Moderator
- retired . . . ¯\_(ツ)_/¯
Less
More
- Posts: 2859
- Thank you received: 649
9 years 1 month ago - 9 years 1 month ago #18313
by jpb
Replied by jpb on topic To Read an Array From CSV File in JBC
Treat the .csv as a sequential file, e.g. :
There are many variants to get single fields from the received data . . .
IN.DELIM = ','
IN.FILE.DIR = '.'
IN.FILE.NAME = 'MYFILE.csv'
OPENSEQ IN.FILE.DIR, IN.FILE.NAME TO F.IN.FILE ELSE
CRT 'Failed to open', IN.FILE.NAME
STOP
END
LOOP
READSEQ IN.LINE FROM F.IN.FILE THEN
CHANGE IN.DELIM TO FM IN IN.LINE
RECEIVED.FIELDS = DCOUNT(IN.LINE,FM)
FOR I = 1 TO RECEIVED.FIELDS
*--> process each field
NEXT I
END
REPEAT
There are many variants to get single fields from the received data . . .
Last edit: 9 years 1 month ago by jpb.
The following user(s) said Thank You: priyankaJacob123
Please Log in or Create an account to join the conversation.
- priyankaJacob123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
9 years 1 month ago #18314
by priyankaJacob123
Replied by priyankaJacob123 on topic To Read next row from CSV File in JBC
Please find the requirement.
I wrote 2-3 arrays (each in next row) in a CSV file, and tried reading this file from my program but it is always reading the first row. Could you tell me if there is an error then.
I wrote 2-3 arrays (each in next row) in a CSV file, and tried reading this file from my program but it is always reading the first row. Could you tell me if there is an error then.
Please Log in or Create an account to join the conversation.
- jpb
- Offline
- Moderator
- retired . . . ¯\_(ツ)_/¯
Less
More
- Posts: 2859
- Thank you received: 649
9 years 1 month ago #18315
by jpb
Replied by jpb on topic To Read next row from CSV File in JBC
Would be easier when you post the relevant part of your routine and an example of the data.
Please Log in or Create an account to join the conversation.
- smleelavathi
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 4 months ago #22228
by smleelavathi
Replied by smleelavathi on topic To Read next row from CSV File in JBC
Hi, Im trying to read csv file from jbc program but it looks like program is not reading csv file contents properly . can u please help me with what might be the issue
Attachment csvandprogram.zip not found
Attachment csvandprogram.zip not found
Attachment csvandprogram.zip not found
Please Log in or Create an account to join the conversation.
- smleelavathi
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 4 months ago #22229
by smleelavathi
Replied by smleelavathi on topic To Read next row from CSV File in JBC
Hi, Im trying to read csv file from jbc program but it looks like program is not reading csv file contents properly . can u please help me with what might be the issue
Please Log in or Create an account to join the conversation.
- VK
- Offline
- Platinum Member
- Globus:G9-G13|TAFC:R05-R23|TAFJ:R19,R23,R24:test
Less
More
- Posts: 1182
- Thank you received: 157
5 years 4 months ago #22230
by VK
Cheers
VK
Replied by VK on topic To Read next row from CSV File in JBC
Hi
what exactly is wrong? Also, which one of 3 attachments contains your program? Or they all are? :))
what exactly is wrong? Also, which one of 3 attachments contains your program? Or they all are? :))
Cheers
VK
Please Log in or Create an account to join the conversation.
- smleelavathi
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
5 years 4 months ago #22232
by smleelavathi
Replied by smleelavathi on topic To Read next row from CSV File in JBC
Hi VK,
Thanks in Advance. Yes all 3 attachments are same and have got uploaded thrice by mistake. when im trying to read lines from csv file it doesnt read contents of all the lines. like for ex: first line is read properly but from next line 2nd, 3rd and 4th are not read at all. it takes some last value after the first line read happened
Thanks in Advance. Yes all 3 attachments are same and have got uploaded thrice by mistake. when im trying to read lines from csv file it doesnt read contents of all the lines. like for ex: first line is read properly but from next line 2nd, 3rd and 4th are not read at all. it takes some last value after the first line read happened
Please Log in or Create an account to join the conversation.
- VK
- Offline
- Platinum Member
- Globus:G9-G13|TAFC:R05-R23|TAFJ:R19,R23,R24:test
Less
More
- Posts: 1182
- Thank you received: 157
5 years 4 months ago #22234
by VK
Cheers
VK
Replied by VK on topic To Read next row from CSV File in JBC
Hi
here's what you have after first READSEQ:
your lines end with CHAR(13) (represented by "~0D") and should end with CHAR(13):CHAR(10) or just CHAR(10)
here's what you have after first READSEQ:
0037 READSEQ IN.LINE FROM F.IN.FILE THEN
jBASE debugger->S
0038 ref = ref + 1
jBASE debugger->V IN.LINE
IN.LINE : ENQUIRY.NAME,PAGE.SIZE,FILE.NAME,FIXED.SELECTION,FIXED.SORT,OPEN.BRACKETS,SELECTION.FIELDS,SEL.LABEL,SEL.FLD.OPER,REQUIRED.SEL,CLOSE.BRACKET,REL.NEXT.FIELD,BUILD.ROTUINE,HEADER,FIELD.NAME,OPERATION,COLUMN,LENGTH.MASK,CONVERSION,COMMENTS ,K.TYPE,DISPLAY.BREAK,FIELD.LBL,FIELD.DISP.TYPE,SECTION,ATTRIBS,TARGET.FIELD,COL.WIDTH,SINGLE.MULTI,ENQUIRY.NAME,SEL.CRIT,LABEL.FIELD,NXT.DESC,DESCRIPT,ATTIRIBUTES,PRODUCT,SHORT.DESC~0DECURRENCY-LIST1,4 19,CURRENCY,,ID,,ID,,,,,,,,ID:CCY.NAME,ID:CCY.NAME,4 8,3L:35L,,,:L,,Ccy:Currency Name,,,,,,S,,,,,,,ST,Currency Drop Down List 2~0DECURRENCY-LIST3,4 19,CURRENCY,,ID,,ID,,,,,,,,ID:CCY.NAME,ID:CCY.NAME,4 8,3L:35L,,,:L,,Ccy:Currency Name,,,,,,S,,,,,,,ST,CURRENCY Drop Down List 3~0DESECTOR-LIST1,4 20,SECTOR,,ID,,ID,,,,,,,,ID:SHORT.NAME,ID:SHORT.NAME,1 2,10R:15L,,,,,Id:Short Name,,,,,,S:S, QUIT SEE @ID,,ID 1,,,,,Sector list 1
your lines end with CHAR(13) (represented by "~0D") and should end with CHAR(13):CHAR(10) or just CHAR(10)
Cheers
VK
Please Log in or Create an account to join the conversation.
- silvergem
- Offline
- Elite Member
- TAFC|R12/R13, TAFJ|R20
Less
More
- Posts: 267
- Thank you received: 21
5 years 3 months ago #22277
by silvergem
Replied by silvergem on topic To Read next row from CSV File in JBC
Is your csv fille came from windows or linux?
windows use crlf while linux use lf as end of line
windows use crlf while linux use lf as end of line
Please Log in or Create an account to join the conversation.
Time to create page: 0.086 seconds