Questions tagged [csv]

Questions on how to import into, extract data from, or exchange data between databases in CSV format (plain text using commas to separate values). Rows are typically denoted by newline characters.

CSV is a file format involving a plain text file with information separated by delimiters with the purpose of storing data in a table-structured format. CSV (Comma Separated Values) files most commonly use a comma delimiter, but other characters can be used such as semicolons, tabs, pipe symbols (|), etc.

The MIME type for CSV files is text/csv.

Information is often stored in CSV format to make it easy to transfer tables of data between applications. Each row of a table is represented as a list of plain text (human-readable) values with a delimiter character between each discrete piece of data. Values may be enclosed in quotes, which is required if they contain the delimiter as a value. The first row of data often contains headers of table's columns, which describe the meaning of the data in each column.

295 questions
23
votes
2 answers

Export remote Postgres table to CSV file on local machine

I have read-only access to a database on a remote server. So, I can execute: COPY products TO '/tmp/products.csv' DELIMITER ','; But on that server I don't have permissions to create/save a file, so I need to do this on my local machine. When I…
tasmaniski
  • 1,195
  • 4
  • 13
  • 16
20
votes
6 answers

MySQL import csv file ERROR 13 (HY000): Can't get stat of /path/file.csv (Errcode: 2)

I am an absolute beginner to MySQL (5.5.34) / Linux (Ubuntu 12.04 LTS)` I have created a simple database with one table. When trying to import data into it via a 'data_test.csv file an error message 13 appears. Exert from Terminal follows: mysql>…
Guillermo
  • 203
  • 1
  • 2
  • 5
16
votes
3 answers

Create a table from a CSV file with headers

I'm seeking to find a way to generate a new MySQL table solely based on the contents of a specified CSV. The CSV files I'll be using have the following properties; "|" delimited. First row specifies the column names (headers), also "|" delimited.…
user58602
  • 161
  • 1
  • 1
  • 3
16
votes
2 answers

Can I query a tab-delimited file from SSMS?

Is it possible to query a tab-delimited file from Sql Server Management Studio to view its data without saving it anywhere? I know you can BULK INSERT from a tab-delimited file using something like: BULK INSERT SomeTable FROM 'MyFile.txt' WITH…
Rachel
  • 8,547
  • 20
  • 51
  • 74
16
votes
2 answers

How can I dump all tables to CSV for a PostgreSQL schema?

I have a database with a lot of schemas in it and I want to dump the each of the table contents to CSV. I'm aware of the COPY command but I'm not sure how to script something that will read all of the tables in a schema and execute the COPY against…
robertpostill
  • 317
  • 1
  • 2
  • 8
14
votes
5 answers

Save Results as CSV *with* headers in SSMS

With SQL Server 2008 R2, when I save the results as a CSV there are no headers. I can work around this by copying and pasting with the "Copy with Headers" , or just grab the headers and paste them in the CSV etc, but is there a better way to do…
Kyle Brandt
  • 2,335
  • 9
  • 29
  • 37
11
votes
5 answers

Import in postgres json data in a csv file

I'm trying to import into postgres a csv file containing the data for a table. One of the column of the table has jsonb type. One line of my csv file contains something like 1,{"a":"b"} Suppose the table has a schema id | smallint …
marcosh
  • 265
  • 1
  • 2
  • 8
10
votes
4 answers

psql denies access to file when using COPY FROM

When I do this: COPY "mytable" FROM '/my/file.csv' WITH DELIMITER AS ',' CSV; On this: -rw-r--r-- 1 peter peter 54819176 2011-07-21 13:17 file.csv psql tells me this: ERROR: could not open file "/my/file.csv" for reading: Permission denied How…
Pete
  • 203
  • 1
  • 2
  • 7
9
votes
4 answers

Read CSV and perform SQL in SQL Server Management Studio

Is it possible in SQL Server Management Studio to read a CSV and perform an SQL update per line? Example data.csv "column1","column2,"column3" "column1","column2,"column3" "column1","column2,"column3" "column1","column2,"column3" …
user598200
  • 191
  • 1
  • 1
  • 2
9
votes
2 answers

Does the PostgreSQL COPY command have the option of choosing which fields to map the CSV columns to?

Does the PostgreSQL COPY command have the option of choosing which fields to map the CSV columns to? The PostgreSQL COPY command appears to expect that the target table matches its columns exactly. Am I missing something or is that how it actually…
vfclists
  • 1,093
  • 4
  • 14
  • 21
8
votes
2 answers

Inserting all csv files into a table in MySQL

I am looking for a way to insert all my csv files into MySQL without having to write several LOAD DATA INFILE statements. I have many csv files I need to insert and the files themselves are very large. I have tried *.csv, but this does not work.
dunce1
  • 201
  • 1
  • 2
  • 4
8
votes
1 answer

Parsing DATE while copying csv file into PostgreSQL table

I have a long series of .csv files, which I want to import into a local database. I believe my query is correct, but there are some problems in parsing DATE and TIMESTAMP columns. PostgreSQL reads these columns expecting an ISO format "yyyy/mm/dd",…
baggiponte
  • 183
  • 1
  • 1
  • 6
8
votes
2 answers

MySQL - CSV UPDATE (not INSERT) into existing table?

I have a table with the following columns: id | name | city The table has 1000 entries in it. I have a CSV file with a limited number of lines like this: id,city 34,Denver 45,Kansas City 145,New York Can I use LOAD DATA INFILE to import my CSV…
Jake Wilson
  • 2,487
  • 8
  • 22
  • 23
7
votes
3 answers

SQLite CSV import won't create a table automatically

According to https://www.sqlite.org/cli.html#csv, sqlite> .mode csv sqlite> .import C:/work/somedata.csv tab1 There are two cases to consider: (1) Table "tab1" does not previously exist and (2) table "tab1" does already exist. In the first case,…
200_success
  • 196
  • 1
  • 11
7
votes
4 answers

Import CSV or JSON file into DynamoDB

I have 1000 CSV files. Each CSV file is between 1 and 500 MB and is formatted the same way (i.e. same column order). I have a header file for column headers, which match my DynamoDB table's column names. I need to import those files into a DynamoDB…
Franck Dernoncourt
  • 2,083
  • 13
  • 34
  • 52
1
2 3
19 20