Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CR+LF EOL not handled correctly in Windows #55

Open
Libarch opened this issue Sep 13, 2018 · 2 comments
Open

CR+LF EOL not handled correctly in Windows #55

Libarch opened this issue Sep 13, 2018 · 2 comments

Comments

@Libarch
Copy link

Libarch commented Sep 13, 2018

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

@fei0x
Copy link

fei0x commented Apr 23, 2021

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

@Libarch
Copy link
Author

Libarch commented Apr 24, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants