0

I keep having issues importing csv files into a table with postgresql using pgadmin4. I get an error saying invalid byte sequence. I've tried importing as win1252, as well as going into the options and changing encoding to utf8 and importing it that way. I've also tried deleting all but a couple rows to narrow down where the invalid character might be, but it always results in the same error no matter which row I keep.

Does anyone know how to address this? It is with multiple files, although I have successfully imported one csv file.

player  fname   lname   pname   pos1    pos2    height  weight  dob forty   bench   vertical    broad   shuttle cone    arm hand    dpos    col dv  start   cteam   posd    jnum    dcp nflid
AA-0025 Ameer   Abdullah    A.Abdullah  RB      69  205 6/13/1993   4.5 24  42.5    130 3.95    6.79    30  8.625   54  Nebraska    Big Ten 2015    MIN RB  31  3   2552374
AA-0050 Aaron   Adams   A.Adams OL      77  305 5/16/1989   5.26    22  28.5    101 4.61    7.61    0   0   0   Eastern Kentucky    Ohio Valley 2013    INA INA 0   0   2541574
AA-0075 Andrew  Adams   A.Adams DB      71  203 10/28/1992  4.54    24  33  118 4.32    6.96    0   0   0   Connecticut American Athletic   2016    TB  S   39  1   2556456
AA-0100 Anthony Adams   A.Adams DL      72  300 6/18/1980   5.13    0   30.5    109 4.59    7.68    0   0   57  Penn State  Big Ten 2003    INA INA 0   0   2505588

I'm simply right clicking the table and selecting import/export, and then filling out the options box. When I tried using copy it gave me a permission error, and when I tried /copy, it gave me a syntax error so I don't know any other way to import csv files as I'm extremely new to SQL and postgresql.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Shawn Schreier
  • 780
  • 2
  • 10
  • 20
  • You may need to post a sample of your file and how you are attempting to import it – Julia Leder Feb 12 '20 at 02:30
  • I've updated the question. Hopefully it helps give more context. – Shawn Schreier Feb 12 '20 at 02:50
  • Have you confirmed that the file is indeed a comma delimited file? No tabs in it? Also add to the question the fact that you are using pgAdmin – Julia Leder Feb 12 '20 at 02:57
  • Yes, I work with the file all the time and it is definitely a csv file. – Shawn Schreier Feb 12 '20 at 02:59
  • Have you checked out suggestions here https://stackoverflow.com/questions/4867272/invalid-byte-sequence-for-encoding-utf8 – Julia Leder Feb 12 '20 at 03:08
  • Yes, I've tried importing it as each of the win options, 1251, 1252, ... 1258, etc. I also did the save and encode it as utf8 with still no luck. I also scanned the document and see no unusual characters that would be obvious issues. – Shawn Schreier Feb 12 '20 at 03:11
  • Try `psql` and irs `\copy` command with `win1252` encoding. If that fails, add the command you tried to the question. – Laurenz Albe Feb 12 '20 at 04:03
  • I've tried the \copy and get a syntax error (ERROR: syntax error at or near "/"). I get the same error regardless of which way the slash is. – Shawn Schreier Feb 12 '20 at 22:28

0 Answers0