LB Booster
« inputCSV »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:46am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: inputCSV  (Read 359 times)
Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx inputCSV
« Thread started on: Nov 6th, 2016, 01:20am »

I have been reading the 'Benefits' section of LBB.
Is this a good use of inputcsv?
(It seems to work as I intended)
r.m.

Code:
INPUTCSV "|", #diary, trans$(t,1), trans$(t,2), trans$(t,3), trans$(t,4), trans$(t,5), trans$(t,6)       
 


which replaces this:

Code:
        line input #diary, trans$
        for n = 1 to 6
           trans$(t,n) = word$(trans$,n,"|")
            if trans$(t,n) = "|" then trans$(t,n) = " "
        next
 
User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: inputCSV
« Reply #1 on: Nov 6th, 2016, 01:28am »

This looks like a better example of inputcsv: 1 line replaces 11.

r.m.

Code:
       ' line input #teacherFile, teacherRec$ 
       ' lname$ = word$(teacherRec$,1,".")
       ' fname$ = word$(teacherRec$,2,".")
       ' initial$ = word$(teacherRec$,3,".")
       ' gender$ = word$(teacherRec$,4,".")
       ' degree$ = word$(teacherRec$,5,".")
       ' major$ = word$(teacherRec$,6,".")
       ' minor$ = word$(teacherRec$,7,".")
       ' years$ = word$(teacherRec$,8,".")
       ' tenure$ = word$(teacherRec$,9,".")
       ' homeRoom$ = word$(teacherRec$,10,".")
        
        INPUTCSV ".", #teacherFile, lname$,fname$,initial$,gender$,degree$,major$,minor$,years$,tenure$,homeroom$
     
      
 
User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: inputCSV
« Reply #2 on: Nov 6th, 2016, 07:52am »

What an incredibly powerful command! And I never even know it existed! (How many times am I going to say that!) There is ALWAYS so much more to learn. Although I HAVE used the InputTo$(#) function.

Jack
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: inputCSV
« Reply #3 on: Nov 6th, 2016, 09:45am »

on Nov 6th, 2016, 01:20am, Alincon wrote:
Is this a good use of inputcsv?

It's a perfectly valid use, although of course you're relying on an LBB-specific extension (being able to specify a delimiter other than a comma) so it won't work in LB 4.5.0.

Sadly, as is well known (and documented at the LB Bug Tracker wiki), the implementation of INPUTCSV in LB 4.5.0 is broken anyway because it doesn't work if the item of data contains embedded quotes. So what promised to be a very useful addition - because it's quite difficult to code an accurate implementation of INPUTCSV in LB 4.04 - turned out to be a disappointment.

I know the LB folks hate me criticising Carl, and I do try not to be unfair, but in this case there's a Wikipedia page on the CSV file format in which examples of such files are listed. Had the LB 4.5.0 implementation been tested with these examples the problem would have been identified.

Anyway, INPUTCSV works correctly in LBB and I've added a couple of enhancements. Firstly you can specify a delimiter other than a comma, allowing for example a standard Tab Separated Value file (such as might be output by Excel) to be read. Secondly it accepts a CSV file with either Windows-style (CRLF) or Unix-style (LF) line terminations because you will commonly encounter the latter.

Richard.
« Last Edit: Nov 6th, 2016, 09:50am by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls