Change file definition of a CSV file - Clipper
This is a discussion on Change file definition of a CSV file - Clipper ; I need to update the contents of an CSV file. I can not use Excel
because I basically need to change the record definition of this CSV
file. Has someone experience with opening CSV files in VO and saving
it ...
-
Change file definition of a CSV file
I need to update the contents of an CSV file. I can not use Excel
because I basically need to change the record definition of this CSV
file. Has someone experience with opening CSV files in VO and saving
it as an (amended) CSV file using VO?
Thks,
Rob
-
Re: Change file definition of a CSV file
Rob
>I need to update the contents of an CSV file. I can not use Excel
> because I basically need to change the record definition of this CSV
> file. Has someone experience with opening CSV files in VO and saving
> it as an (amended) CSV file using VO?
CSV are text files so using FOpen()/Fread()/FClose() would be the way to go
OR
simpler still is use the FileObj class that's in the old VO25Forum Library.
Eg
oFile := FileObj{ cFileName, FO_READWRITE }
DO WHILE ! oFile:EOF
Aadd( anArray, oFile:Read() )
ENDDO
// Do whatever with the array
CYA
Steve
-
Re: Change file definition of a CSV file
Rob,
Importing the whole file (in an array), than append/modify the array and
write the full array seems the logical thing to do to me.
John
Rob van Erk schreef:
> I need to update the contents of an CSV file. I can not use Excel
> because I basically need to change the record definition of this CSV
> file. Has someone experience with opening CSV files in VO and saving
> it as an (amended) CSV file using VO?
>
> Thks,
> Rob
-
Re: Change file definition of a CSV file
Thanks for the feedback.
I got the impression that a CSV file is not just a file that you can
edit with, for example Notepad or the DOS editor. If I do and save the
file again the contents seems to be changed and it looks like it is
not a CSV file anymore afterwards. But, reading your below comments it
should be not so difficult so, I will investigate further. Thanks.
Brgds,
Rob
-
Re: Change file definition of a CSV file
Rob,
Am Mon, 29 Sep 2008 23:50:08 -0700 (PDT) schrieb Rob van Erk:
> Thanks for the feedback.
>
> I got the impression that a CSV file is not just a file that you can
> edit with, for example Notepad or the DOS editor. If I do and save the
> file again the contents seems to be changed and it looks like it is
> not a CSV file anymore afterwards. But, reading your below comments it
> should be not so difficult so, I will investigate further. Thanks.
>
> Brgds,
> Rob
CSV is one implementation of a delimited text file
perhaps this is a good point to start:
http://en.wikipedia.org/wiki/Comma-separated_values
Werner
--
German phpBB-Board for Visual Objects user:
http://www.weepee.eu/forum/vo/
divUtilies: new version 14th June, 2006
http://www.weepee.eu/vo/DivUtilities/DivUtilities.zip
-
Re: Change file definition of a CSV file
Rob van Erk wrote:
> Thanks for the feedback.
>
> I got the impression that a CSV file is not just a file that you can
> edit with, for example Notepad or the DOS editor. If I do and save the
> file again the contents seems to be changed and it looks like it is
> not a CSV file anymore afterwards. But, reading your below comments it
> should be not so difficult so, I will investigate further. Thanks.
>
> Brgds,
> Rob
NO, it is just a text file as any other!
Rob, if you need to manipulate textfiles: see Fabrice's Filebin class
(in Fabtools lib). It makes it really easy!
--
Paul
-
Re: Change file definition of a CSV file
Thanks for the support. I will check if opening the files with another
editor (or Fabrice's Filebin class) solves the problem. It is very
strange. I have a CSV file and if I open this CSV file with DOS editor
(in Windows XP) the text is something like:
AIT RTM 626465a 06/12/08 EUR 0 0
if I just open the same file in Excel the text is more or less the
same but with separators (kind of blocks):
AIT RTM 626465a 06/12/08 EUR 0 0
If I now simple open the same unchanged file in DOS again and change
the text from
AIT RTM 626465a 06/12/08 EUR 0 0
into
AIT RTM 626465a 06/12/08 EUR 0 0 TEST
save it and open it in Excel (2003) again than the text reads:
AIT RTM 626465a 06/12/08 EUR 0 0 TEST
So, basically it differs from the original file now and as expected...
it is rejected by our other system. That's the reason why I get the
impression that an CSV file is more than only pure text. Perhaps I
have to consider to open the file in an editor that is capable to read
the exact contents of CSV files...
I will investigate further. It is not a real VO question but will try
if I can solve the issue with Fabrice tools or other.
Brgds,
Rob
-
Re: Change file definition of a CSV file
Rob,
just a thought: open your files with a hex editor and look for the
starting bytes - these days ANSI vs. UTF plays some tricks with us ;-)
Karl
-
Re: Change file definition of a CSV file
Rob van Erk wrote:
> Thanks for the support. I will check if opening the files with another
> editor (or Fabrice's Filebin class) solves the problem. It is very
> strange. I have a CSV file and if I open this CSV file with DOS editor
> (in Windows XP) the text is something like:
>
> AIT RTM 626465a 06/12/08 EUR 0 0
>
> if I just open the same file in Excel the text is more or less the
> same but with separators (kind of blocks):
>
> AIT RTM 626465a 06/12/08 EUR 0 0
>
> If I now simple open the same unchanged file in DOS again and change
> the text from
>
> AIT RTM 626465a 06/12/08 EUR 0 0
>
> into
>
> AIT RTM 626465a 06/12/08 EUR 0 0 TEST
>
> save it and open it in Excel (2003) again than the text reads:
>
> AIT RTM 626465a 06/12/08 EUR 0 0 TEST
>
> So, basically it differs from the original file now and as expected...
> it is rejected by our other system. That's the reason why I get the
> impression that an CSV file is more than only pure text. Perhaps I
> have to consider to open the file in an editor that is capable to read
> the exact contents of CSV files...
>
> I will investigate further. It is not a real VO question but will try
> if I can solve the issue with Fabrice tools or other.
>
> Brgds,
> Rob
>
>
>
Rob,
it is not a CSV file because (as the name says: comma-separated value)!)
the fields should be sepatared by commas!
It is a delimited file, in which case the delimiter could be a space, a
tab etc...
anyway it doesn't make a lot of a difference: it are all text files. The
CSV or TAB or TXT extension is in fact quite meaningless, you can save
the file with whatever extension you like, it will remain a plain text
file.
As Karl suggest: open it with a hex editor and look what those
characters are that Excel can't show...but your "other system" that
reads this files does seem to want them! It is probably some kind of
delimiter like a tab, a pipe or something else your DOS-editor doesn't
show.
Now, personnally I would use a Windows text editor - DOS is a bit passe
<g>
When saving in Excel, how do you save it? Not as Comma-separated I
guess, otherwise, you would get commas in between.
Also, if there's one tool I wouldn't use to edit/save text files than it
is Excel.
Just use a text editor. If you need something more powerful than
Notepad, google for Editpad (written by a Belgian, BTW).
--
Paul
-
Re: Change file definition of a CSV file
Thanks.
I will try to use another editor. Opening and saving the file in Excel
is basically not giving me the "flexibility" to change something in
the fileformat. For that reason I considered to open with VO-code and
save it again. I will google for Editpad,
thanks for all the support on this.
Rob