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

Feature Request -> Uploading csv #6094

Open
Bryze opened this Issue Oct 4, 2017 · 8 comments

Comments

Projects
None yet
6 participants
@Bryze
Copy link

Bryze commented Oct 4, 2017

Spending some time in metabase, I couldn't find an option to create visualizations based on csv's.
I apologise if the option is present ( in that case, please guide me on where to find it )

If not, it would be lovely to have this as a feature

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

@salsakran

This comment has been minimized.

Copy link
Contributor

salsakran commented Oct 18, 2017

related to #1704

@hagen

This comment has been minimized.

Copy link

hagen commented Oct 26, 2017

Perhaps another option @salsakran (having read #1704) is to connect to Google Sheets/ Microsoft Graph API to pull and query spreadsheet data? This alleviates the need to store csvs, either in H2 or a wroteable database. It’s also easy to upload csvs to these platforms.

@arita37

This comment has been minimized.

Copy link

arita37 commented Mar 2, 2018

We need static load from local folder when we cannot access external datasource....

@aadrian

This comment has been minimized.

Copy link

aadrian commented Jul 11, 2018

@Bryze would #7534 fulfill this?

@Bryze

This comment has been minimized.

Copy link
Author

Bryze commented Jul 11, 2018

@aadrian yes this does it. Also, I was wondering what sort of options can this support. I mean, it would be less than the sql query thingy but still I'll expect basic aggregations.

PS: While this may be out of context, but just reminded me of apache spark. It also provides various ways of transforming data fetched from a csv. (Incase, anyone needs ideas)

@aadrian

This comment has been minimized.

Copy link

aadrian commented Jul 11, 2018

@Bryze Query should be the same as with any Relational (SQL) DB, since AFAIK one would see each CSV file as a H2 table.

@Bryze

This comment has been minimized.

Copy link
Author

Bryze commented Jul 11, 2018

@aadrian Yes, in that case we are to assume that the output table from querying the db will be same to the table in the input file provided as csv

@vvaezian

This comment has been minimized.

Copy link

vvaezian commented Feb 8, 2019

One fairly easy workaround is to first convert the CSV file to SQLite, and then import it to Metabase as SQLite db.

Code in Python (based on this answer):

import csv, sqlite3

con = sqlite3.connect("C:\\Users\\John\\testdb.db") # first create an empty file to save the db
cur = con.cursor()
cur.execute("CREATE TABLE t ('Col1' text, 'Col2' text);")

with open('C:\\Users\\John\\test.csv','rb') as csvFile:
    # csv.DictReader uses first line in file for column headings by default
    dr = csv.DictReader(csvFile) # comma is the default delimiter
    to_db = [(i['Col1'], i['Col2']) for i in dr]

cur.executemany("INSERT INTO t ('Col1','Col2') VALUES (?, ?);", to_db)
con.commit()
con.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment