Import CSV data having the fewer columns than in the header #12092
Unanswered
ashokgudur
asked this question in
Q&A
Replies: 3 comments
-
ignore_errors will just skip the faulty data, which is everything here |
Beta Was this translation helpful? Give feedback.
0 replies
-
It seems like you want duckdb.sql("""
from read_csv('a.csv', null_padding=true)
""")
# ┌────────────┬──────────┬─────────────┐
# │ MSISDN │ PROVIDER │ NATIONALITY │
# │ int64 │ varchar │ varchar │
# ├────────────┼──────────┼─────────────┤
# │ 9482722796 │ BSNL │ NULL │
# │ 9483416186 │ AIRTEL │ NULL │
# │ 9686073433 │ AIRTEL │ NULL │
# │ 9008331295 │ BSNL │ NULL │
# └────────────┴──────────┴─────────────┘ |
Beta Was this translation helpful? Give feedback.
0 replies
-
yes Worked for me. only null_padding=true is enough but I have some errored rows in the file. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a CSV file that is separated with | char.
The header has 3 columns defined but the data has only 2 columns
For example:
MSISDN|PROVIDER|NATIONALITY
9482722796|BSNL
9483416186|AIRTEL
9686073433|AIRTEL
9008331295|BSNL
However the command
SELECT * FROM read_csv('sdrdata.txt')
reads all columns in to single column
If I give SELECT * FROM read_csv('sdrdata.txt',ignore_errors=true)
doesn't read any data. Outputs only empty columns,
Can anybody help me?
Beta Was this translation helpful? Give feedback.
All reactions