| Subject |
Re: separator for CSV file to be imported into dBase |
| From |
Joseph <ja@js-consulting.pro> |
| Date |
Sun, 04 Oct 2020 10:55:44 -0400 |
| Newsgroups |
dbase.getting-started |
Hi Mervyn,
My response was spontaneous and I forgot to translate it! Usually I always use English since dBase news has existed!
J.
Mervyn Bick Wrote:
> On 2020/10/01 17:39, Joseph wrote:
> > Bonjour Jean,
> > Je n'ai pas lu toutes le suggestions mais ayant eu plusieurs fois ce probleme, j'ai choisi un moyen externe, avec un editeur comme Notepad++:
> > 1- remplacer toutes les virgules par des points
> > 2- puis tous le point-virgules par des virgules.
> > Le csv en sortie est alors compatible pour l'importation.
> > Bonne contination !
> > Bien cordialement
> > Joseph
> >
> > (pour une fois que je peux écrire en français, je ne m'en prive pas !)
>
> Please stick to English for this newsgroup. If writing in English is a
> problem Google Translate or DeepL translations, while sometimes not
> exact, are usually good enough for us to understand.
>
> Using a text editor to manually rework a source file is one way of doing
> it but it can be a nuisance if one has many files to deal with. If
> dealing with this specific format of file is going to be a regular task
> then a little program is not difficult to write.
>
> The little program below took about twenty minutes to type and test.
> All it requires is for the source file and target .dbf names to be
> edited. A few more minutes work will be all it needs to allow the names
> to passes as parameters.
>
> *********************
> cSource = 'test_semicolon.csv'
> cTarget = 'test_semicolon.dbf'
> clear
> s = seconds()
> _app.allowYieldOnMsg := true
> set procedure to :duflp:stringex.cc
> q = new query()
> q.sql = 'select * from '+cTarget
> q.active = true
> f = new file()
> f.open(cSource)
> nCount = 0
> do while not f.eof()
> cStr = f.gets()
> aArray = new stringex(cStr).breakstring(';')
> q.rowset.beginappend()
> for n = 1 to aArray.size
> q.rowset.fields[n].value = aArray[n]
> next
> q.rowset.save()
> nCount ++
> if nCount%50 = 0
> ?nCount+ ' Records'
> endif
> enddo
> ?nCount+ ' Records'
> ?seconds()-s +' Seconds'
> f.close()
> q.active = false
> **************************
>
> Mervyn.
>
>
>
>
|
|