Python-DSV is a Python module for importing and exporting DSV (delimiter separated values) files.  
DSV is a generalization of CSV (comma separated values).  CSV is a common file format used by many programs to import and export data.





Basic use:

    from DSV import DSV

    data =
    qualifier = DSV.guessTextQualifier(data) # optional
    data = DSV.organizeIntoLines(data, textQualifier = qualifier)
    delimiter = DSV.guessDelimiter(data) # optional
    data = DSV.importDSV(data, delimiter = delimiter, textQualifier = qualifier)
    hasHeader = DSV.guessHeaders(data) # optional

If you know the delimiters, qualifiers, etc, you may skip the optional 'guessing' steps as they rely on heuristics anyway (although they seem to work well, there is no guarantee they are correct). What they are best used for is to make a good guess regarding the data structure and then let the user confirm it.

As such there is a 'wizard' to aid in this process (use this in lieu of the above code - requires wxPython):

    from DSV import DSV

    dlg = DSV.ImportWizardDialog(parent, -1, 'DSV Import Wizard', filename)
    headers, data = dlg.ImportData() # may also return None

The dlg.ImportData() method may also take a function as an optional argument specifying what it should do about malformed rows.  See the example at the bottom of this file. A few common functions are provided in this file (padRow, skipRow, useRow).

There is a more complete example at the bottom of   Just type python at the command prompt to see it in action.

Good Luck!


SourceForge Logo