Sorry, an error occurred while loading the content.

## Reading in comma separated data

Expand Messages
• Dear All, I m trying to read in a file of the form 5,3,7,12,5 23,5,7,8,1 2,34,9,8,3 etc. Is there a way to read in one number at a time rather than the whole
Message 1 of 4 , Jul 6, 2005
• 0 Attachment
Dear All,

I'm trying to read in a file of the form

5,3,7,12,5
23,5,7,8,1
2,34,9,8,3 etc.

Is there a way to read in one number at a time rather than the
whole line. The following seems to ignore everything after the
first number and runs out of data

610 FOR Rows=1 TO R
620 FOR Columns=1 TO C
630 INPUT #1, a, : Arrayfirst(Rows,Columns) = a
640 NEXT Columns
660 NEXT Rows

Yours dimly,

Matthew.
• Not the simplest way: for/nxt input #1,a\$ (reads on line into a\$) with instr\$ and mid\$ read out position of , and then the numbers in between nxt (for next
Message 2 of 4 , Jul 6, 2005
• 0 Attachment
Not the simplest way:

for/nxt
input #1,a\$ (reads on line into a\$)
with instr\$ and mid\$ read out position of "," and then the numbers in
between
nxt (for next line)

yours
• Matthew, If you always have a fixed number of columns, try this: for i = 1 to n input a(i,1),a(i,2),a(i,3),a(i,4),a(i,5) next i Not very elegant, but hey?
Message 3 of 4 , Jul 6, 2005
• 0 Attachment
Matthew,

If you always have a fixed number of columns, try this:

for i = 1 to n
input a(i,1),a(i,2),a(i,3),a(i,4),a(i,5)
next i

Not very elegant, but hey?

Regards,
Jeremy Gardiner

--- In chipmunkbasicforum@yahoogroups.com, "bssmaw"
<bssmaw@y...> wrote:

> I'm trying to read in a file of the form
>
> 5,3,7,12,5
> 23,5,7,8,1
> 2,34,9,8,3 etc.
>
> Is there a way to read in one number at a time
• The built-in field\$(a\$, n, , ) function will return comma seperated fields directly.
Message 4 of 4 , Jul 10, 2005
• 0 Attachment
The built-in field\$(a\$, n, ",") function will return comma seperated fields directly.

--- In chipmunkbasicforum@yahoogroups.com, Marcel Spisak <mspisak@g...>
wrote:
> Not the simplest way:
>
> for/nxt
> input #1,a\$ (reads on line into a\$)
> with instr\$ and mid\$ read out position of "," and then the numbers in
> between
> nxt (for next line)
>
> yours
Your message has been successfully submitted and would be delivered to recipients shortly.