Subject Re: separator for CSV file to be imported into dBase
From Jean R. from Paris <jrsp@sovenibe.fr>
Date Wed, 23 Sep 2020 10:30:17 -0400
Newsgroups dbase.getting-started

Akshat Kapoor Wrote:

> > I have some large CSV files to get imported into dBase.
> > the fields separators being ";" dBase does not like that
> > Since I cannot change the fields separators. How could i go around the limitation and find a way to import the CSV file into dBase
>
>
> Good Evening Jean,
> You will have to opt in for DIY route.
>
> The following code should give you some ideas. It is replacing Tab (chr
> 9) with ,
>
> Regards
> Akshat
>
>        set safety off
>        use attend.dbf excl
>        zap
>        fout = new file()
>        fin = new file()
>        in_file = getfile("AGL_0001.txt")
>        if not empty(in_file)
>           fin.open(in_file)
>           fout.create("attendance.csv")
>           for a = 1 to 5
>              chr_str = fin.readln()
>           endfor
>           do while not fin.eof()
>              chr_str = fin.readln()
>              do while at(chr(9),chr_str) >0
>                 chr_str = stuff(chr_str,at(chr(9),chr_str),1,",")
>              enddo
>              fout.writeln(chr_str)
>           enddo
>           fin.close()
>           fout.close()
>           append from attendance.csv delimited with ","
>           go top
>           mname = attend->name
>           mdate = new date(attend->date_time)
>           do while not eof()
>              skip
>              if mname = attend->name and (mdate - new
> date(attend->date_time))*24*60*60 <45
>                 delete
>              else
>              endif
>              mname = attend->name
>              mdate = new date(attend->date_time)
>           enddo
>        endif
>        use

Thank you for prompt comments Akshat

The problem seems to be that I also have a lot of uncontrolled "," into the text fields  (it means "," characters used by the client users into text fields  which I have no way to avoid or prevent because this CSV file is extracted from aonother data base).

Any other suggestion would be appreciated.

Thank you
Jean R. from Paris


This means that the new separators will definitely mix in with the "," form the text in thext fields.