Re: parsing a dbIII file



korovev76@xxxxxxxxx wrote:
Hello everybody, I'm new to python (...I work with cobol...)

I have to parse a file (that is a dbIII file) whose stucture look like
this:
|string|, |string|, |string that may contain commas inside|, 1, 2, 3, |
other string|

Is there anything in python that parses this stuff?


thanks a lot
korovev

That's not a standard dBaseIII data file though, correct? It looks more like something that was produced *from* a dBaseIII file.

If the format is similar to Excel's CSV format then the csv module from Python's standard library may well be what you want. Otherwise there are parsers at all levels - one called PyParsing is quite popular, and I am sure other readers will have their own suggestions.

I am not sure whether the pipe bars actually appear in your data file, so it is difficult to know quite exactly what to suggest, but I would play with the file in an interactive interpreter session first to see whether csv can do the job.

Good luck with your escape from COBOL!

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

.



Relevant Pages

  • Re: Fastest way to read data to populate combo controls?
    ... dumping the whole thing into a CSV and parse it using VB. ... When you talk about using a CSV, Ralph, I have no clue how VB would ... The Excel macro creates a Word document with six tables: ... If bPath Then ...
    (microsoft.public.vb.general.discussion)
  • Re: inherited cobol app., cant run (xm.exe)?
    ... way to decipher the header in a data file? ... Now, obviously this isn't a perfect parse, but it's a start. ... meaning it's considered equipment in this system. ... The file header is described in documentation ...
    (comp.lang.cobol)
  • Re: CSV files
    ... no but next time I need to parse a csv I shall certainly look into it. ... Mark Broadbent ... "Konrad L. M. Rudolph" wrote in message ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Fastest way to read data to populate combo controls?
    ... dumping the whole thing into a CSV and parse it using VB. ... When you talk about using a CSV, Ralph, I have no clue how VB would ... The Excel macro creates a Word document with six tables: ... "How To Use ADO with Excel Data from Visual Basic or VBA"http://support.microsoft.com/kb/257819 ...
    (microsoft.public.vb.general.discussion)
  • Re: I love csv format
    ... Data that can include the record separator character. ... There are ways around both the above but their is no CSV standard. ... It is not as simple, for example, to parse a CSV file generated by ... Excel in AWK if text fields can include newlines, or commas, or double ...
    (comp.programming)