[GRASS-dev] [GRASS GIS] #2692: v.in.ascii does not handle text in qoutes
GRASS GIS
trac at osgeo.org
Wed Jun 17 03:18:25 PDT 2015
#2692: v.in.ascii does not handle text in qoutes
-------------------------+-------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.0.1
Component: Default | Version: svn-trunk
Resolution: | Keywords: CSV, doublequote, singlequote, text
CPU: | delimiter
Unspecified | Platform: Unspecified
-------------------------+-------------------------------------------------
Comment (by mlennert):
Replying to [comment:4 mlennert]:
> Replying to [comment:3 glynn]:
> > Replying to [comment:2 mlennert]:
> > > The attached patch seems to solve the problem for me, but it feels
like a quick fix and there probably is a better way...
> > Simply removing the quotes isn't sufficient to support CSV. It's
necessary to treat the field separator as a normal character when it
occurs within a quoted field (that's the point of using quotes), and also
to replace two consecutive quotes with a single quote (so that the quote
character itself can occur within a field).
> >
> > For that, an explicit state machine is likely to be more legible than
ad-hoc logic.
>
> Sounds like a fun programming challenge (for it's a challenge at least),
but I wonder whether we couldn't just integrate the work of others in the
same domain, notably [http://sourceforge.net/projects/libcsv/ libcsv].
It's GPL (2 or higher) and its fairly lightweight, so we could just
integrate it into the GRASS source (although Debian ships it as a package
as well, don't know for other distributions, nor for OSX and Windows).
AFAICS, there have been no modifications since 2013, so it does not look
like a heavy dependency to track.
Another option would be to use [https://docs.python.org/2/library/csv.html
Python's csv module] and rewrite v.in.ascii in Python...
Moritz
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2692#comment:5>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list