pgfutter icon indicating copy to clipboard operation
pgfutter copied to clipboard

CR+LF EOL not handled correctly in Windows

Open Libarch opened this issue 6 years ago • 2 comments

Using pgfutter_windows_amd64.exe binary on Windows 10, with CSV files edited in Notepad++ in UTF-8 encoding: If the EOL delimiter is set to CR+LF (ie Windows standard), a CR (ie ASCII 13) is appended to each entry in the last column if it's a text field, and if not an additional row of blank entries is added to the table. If the EOL is set to LF only (ie Linux standard), then pgfutter fails with this exception:

2 columns
[serial_id some_text]
 127 B / 127 B [==============================================================================================] 100.00%panic: runtime error: index out of range

goroutine 1 [running]:
main.copyCSVRows(0xc04214e190, 0xc042146140, 0x0, 0x740f3a, 0x1, 0xc04214a500, 0x2, 0x2, 0xc04214e190, 0x0, ...)
        /usr/src/pgfutter/csv.go:99 +0x74e
main.importCSV(0xc04200e180, 0x39, 0xc0420140e0, 0x64, 0x743323, 0x6, 0xc04200a980, 0x11, 0x0, 0x0, ...)
        /usr/src/pgfutter/csv.go:172 +0x3fd
main.main.func2(0xc04209c420, 0xc042041200, 0xc04209c420)
        /usr/src/pgfutter/pgfutter.go:164 +0x396
github.com/codegangsta/cli.HandleAction(0x6e4f40, 0x75a8e0, 0xc04209c420, 0x0, 0xc0420347e0)
        /gopath/src/github.com/codegangsta/cli/app.go:501 +0xd9
github.com/codegangsta/cli.Command.Run(0x7412f4, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x74d1f6, 0x18, 0x0, ...)
        /gopath/src/github.com/codegangsta/cli/command.go:165 +0x4c2
github.com/codegangsta/cli.(*App).Run(0xc0420f2000, 0xc042064000, 0xb, 0x10, 0x0, 0x0)
        /gopath/src/github.com/codegangsta/cli/app.go:259 +0x747
main.main()
        /usr/src/pgfutter/pgfutter.go:170 +0xcd5

I used the attached 2 files to test this: test_data_with_CRLF.csv.txt test_data_with_LF.csv.txt

Libarch avatar Sep 13 '18 12:09 Libarch

This is tripping me up. Do yo have any workarounds? I have the same experience in Ubuntu.

fei0x avatar Apr 23 '21 17:04 fei0x

IIRC you can manually add an additional 'dummy' text column at the end which usually works. But these days I use DBeaver for quick imports into PostgreSQL and haven't used pgfutter for some time, sorry.

Libarch avatar Apr 24 '21 10:04 Libarch