#3155: inconsistent newlines handling on Windows -------------------------+------------------------- Reporter: annakrat | Owner: grass-dev@… Type: defect | Status: new Priority: normal | Milestone: 7.2.0 Component: LibVector | Version: svn-trunk Keywords: newline | CPU: Unspecified Platform: MSWindows 8 | -------------------------+------------------------- Function [https://grass.osgeo.org/programming7/ascii_8c_source.html#l00336 Vect_write_ascii] uses:
{{{ fprintf(ascii, "%s", HOST_NEWLINE); }}} where HOST_NEWLINE is defined as '\r\n' on Windows. Other modules like v.info use: {{{ fprintf(stdout, "north=%s\n", tmp1); }}} This is problem when you process the output in Python: {{{ >>> output_points = grass.read_command("v.out.ascii", input='hospitals', format="point", separator=",").strip() >>> repr(output_points) '697237.5638615,182012.65540056,1\r\r\n704563.1878615,183568.90640056,2\r\r\n371094.1568615,274897.21940056,3\r\r\n640607.6248615,224673.12440056,4\r\r\n640952.4998615,224309.56340056,5\r\r\n670385.0618615,229717.53040056,6\r\r\n643879.5628615,230462.43740056,7\r\r\n636274.0638615,229165.37540056,8\r\r\n627390.7508615,202760.56240056,9\r\r\n646823.5628615,226063.35940056,10\r\r\n206065.7348615,195917.60840056,11\r\r\n444744.4678615,280199.56340056,12\r\r\n501025.1878615,179551.84440056,13\r\r\n566335.3748615,111190.14840056,14\r\r\n566327.6258615,111195.04740056,15\r\r\n671357.9988615,139627.76540056,16... }}} but: {{{ x= grass.read_command('v.info', map='hospitals', flags='g') repr(x) 'north=308097.937400562\r\nsouth=20235.5644005626\r\neast=914347.8748615\r\nwest=156998.1718615\r\ntop=0.000000\r\nbottom=0.000000\r\n' }}} so you have '\r\r\n' instead of '\r\n' which results in problems: {{{ >>> output_points.splitlines() ['640607.6248615,224673.12440056,4', '', '640952.4998615,224309.56340056,5', ' ', ...] }}} Should we stop using 'HOST_NEWLINE' then? -- Ticket URL: <https://trac.osgeo.org/grass/ticket/3155> GRASS GIS <https://grass.osgeo.org> _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev