[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2010-04-19T22:01:03-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/3214 2010-04-19T22:01:03-05:00 2010-04-19T22:01:03-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20578#p20578 <![CDATA[Counting fields in a record]]> :D
__________________
Watch The Losers Movie Online Free

Statistics: Posted by canarymu — Mon Apr 19, 2010 10:01 pm


]]>
2010-02-01T15:10:20-05:00 2010-02-01T15:10:20-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20409#p20409 <![CDATA[Counting fields in a record]]> Statistics: Posted by dbish — Mon Feb 01, 2010 3:10 pm


]]>
2010-02-01T13:29:09-05:00 2010-02-01T13:29:09-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20408#p20408 <![CDATA[Counting fields in a record]]>

Code:

DO UNTIL EOF(1)  LINE INPUT #1, dataline$  IF LEN(dataline$) THEN   'data must have a length     datacount = 1  'assume one piece of data w/o comma     FOR d = 1 TO LEN(dataline$)        IF MID$(dataline$, d, 1) = "," THEN datacount = datacount + 1     NEXT  ELSE : datacount = 0 ' no data on file line  END IF  PRINT dataline$, datacount    ' your other code hereLOOP
You can place the data and counts into arrays for later use.

Statistics: Posted by burger2227 — Mon Feb 01, 2010 1:29 pm


]]>
2010-02-01T10:17:29-05:00 2010-02-01T10:17:29-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20407#p20407 <![CDATA[Counting fields in a record]]>
I am assuming I would do this in some sort of loop like:

COMMACOUNT=0
FOR i = 1 to LINEDATALENGTH-1
if MID$(LINEDATA,i,i+1)="," Then COMMACOUNT=COMMACOUNT+1
Next i

Is this what you were thinking? (I can fine tune the code - just a concept question.)

Statistics: Posted by dbish — Mon Feb 01, 2010 10:17 am


]]>
2010-01-30T18:39:10-05:00 2010-01-30T18:39:10-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20394#p20394 <![CDATA[Counting fields in a record]]>
Count the commas if so by scanning the LINE INPUT text string with MID$.

"23,456,467,22" ' and add 1 to the final count

Commas would not follow the last entry.

Statistics: Posted by burger2227 — Sat Jan 30, 2010 6:39 pm


]]>
2010-01-30T02:08:13-05:00 2010-01-30T02:08:13-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20390#p20390 <![CDATA[Counting fields in a record]]>
Thanks

Statistics: Posted by dbish — Sat Jan 30, 2010 2:08 am


]]>
2010-01-30T02:03:46-05:00 2010-01-30T02:03:46-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=20389#p20389 <![CDATA[Counting fields in a record]]>
My FB programs currently read in a CSV file that is approximately 300,000 rows by exactly 19 data items per row. I first use a Line Input routine to determine the number of rows and then read the file sequentially into memory where I then do manipulations and save as a new file.

===============
i = 0
OPEN FILENAMECURRENT$ FOR INPUT AS #1
DO WHILE NOT EOF(1)
i = i + 1
LINE INPUT #1, OPTIONLINE$
CHAR1$ = LEFT$(OPTIONLINE$, 1)
IF CHAR1$ = "" THEN EXIT DO
LOOP
CLOSE #1
FINALROWNUMBER_MASTER% = i
OPEN FILENAMECURRENT$ FOR INPUT AS #1
FOR i = 1 TO FINALROWNUMBER_MASTER%
FOR j = 1 TO 19
INPUT #1, WorkingRawArray$(i, j)
NEXT
NEXT
CLOSE #1
======================

My data vendor now tells me that due to extraneous events it is possible that some rows will have 19 items and some will have 20 items. I think I want to do the same line input routine to determine the number of rows but then read each line in one at a time. For rows with 19 items I will add an extra +",DUMMY" value at the end to cause all rows to be the same data item length. I can probably figure that part out myself.

My problem is what would be a good way to determine whether there are 19 or 20 data items in the row?

Any help would be appreciated.

Thanks

dbish

Statistics: Posted by dbish — Sat Jan 30, 2010 2:03 am


]]>