csv

Piping data from a python script into a .csv or .txt file

痴心易碎 提交于 2020-04-17 19:00:24
问题 I want to monitor air quality inside my flat (downstairs neighbor is an avid smoker). For so doing, I have a Raspberry Pie 3 Model B+ connected with an Enviro+. While in the terminal I can run the script that measures small particles. python particulates.py cf. https://github.com/pimoroni/enviroplus-python/blob/master/examples/particulates.py It then runs and display the data in the terminal, like in the picture below: (yes, I am better at lego-ing, than coding). I am interested in keeping a

python: use CSV reader with single file extracted from tarfile

寵の児 提交于 2020-04-16 05:49:41
问题 I am trying to use the Python CSV reader to read a CSV file that I extract from a .tar.gz file using Python's tarfile library. I have this: tarFile = tarfile.open(name=tarFileName, mode="r") for file in tarFile.getmembers(): tarredCSV = tarFile.extractfile(file) reader = csv.reader(tarredCSV) next(reader) # skip header for row in reader: if row[3] not in CSVRows.values(): CSVRows[row[3]] = row All the files in the tar file are all CSVs. I am getting an exception on the first file. I am

python: use CSV reader with single file extracted from tarfile

元气小坏坏 提交于 2020-04-16 05:49:11
问题 I am trying to use the Python CSV reader to read a CSV file that I extract from a .tar.gz file using Python's tarfile library. I have this: tarFile = tarfile.open(name=tarFileName, mode="r") for file in tarFile.getmembers(): tarredCSV = tarFile.extractfile(file) reader = csv.reader(tarredCSV) next(reader) # skip header for row in reader: if row[3] not in CSVRows.values(): CSVRows[row[3]] = row All the files in the tar file are all CSVs. I am getting an exception on the first file. I am

how to import psv data into Microsoft Access

余生长醉 提交于 2020-04-16 02:32:34
问题 I am using Access 2016, I have a psv (pipe delimetered csv) to be imported in a Access database, when I select import from text, the psv file doesn't show up in the File Browser: Nor can I specify the psv directly: How can I import psv into Access? Thank you very much. UPDATE: Per suggestion, after I changed the psv to txt and specify it to import, I stuck below: It DOESN't accept pipe (or maybe any character) in the Other option. (wouldn't this look like a BUG if it doesn't accept any input

Write tweets from rtweets package to csv

六眼飞鱼酱① 提交于 2020-04-11 18:32:24
问题 I'm unable to write tweets from search_tweet() in 'rtweet' package to csv. It throws the following error: Here's a link to the question I previously asked, that has details on the type of search_tweet() object creates: Class and type of object is different in R. How should I make it consistent? How should I write this files as csv? library(rtweet) comments <- search_tweets( queryString, include_rts = FALSE, n = 18000, type = "recent", retryonratelimit = FALSE) write_csv(comments, "comments

Combining multiple csv files into one csv file

拜拜、爱过 提交于 2020-04-11 17:13:06
问题 I am trying to combine multiple csv files into one, and have tried a number of methods but I am struggling. I import the data from multiple csv files, and when I compile them together into one csv file, it seems that the first few rows get filled out nicely, but then it starts randomly inputting spaces of variable number in between the rows, and it never finishes filling out the combined csv file, it just seems to continuously get information added to it, which does not make sense to me

Flask button to save table from query as csv

Deadly 提交于 2020-04-11 12:21:52
问题 I have a flask app that runs a query and returns a table. I would like to provide a button on the page so the user can export the data as a csv. The problem is that the query is generated dynamically based on form input. @app.route('/report/<int:account_id>', methods=['GET']) def report(account_id): if request == 'GET': c = g.db.cursor() c.execute('SELECT * FROM TABLE WHERE account_id = :account_id', account_id=account_id) entries = [dict(title=row[0], text=row[1]) for row in c.fetchall()]

XML to CSV Python

▼魔方 西西 提交于 2020-04-11 11:56:30
问题 The XML data(file.xml) for the state will look like below <?xml version="1.0" encoding="UTF-8" standalone="true"?> <Activity_Logs xsi:schemaLocation="http://www.cisco.com/PowerKEYDVB/Auditing DailyActivityLog.xsd" To="2018-04-01" From="2018-04-01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cisco.com/PowerKEYDVB/Auditing"> <ActivityRecord> <time>2015-09-16T04:13:20Z</time> <oper>Create_Product</oper> <pkgEid>10</pkgEid>

Remove specific character from a csv file, and rewrite to a new file

泪湿孤枕 提交于 2020-04-11 07:57:25
问题 I have a VBA macro pulling stock data every 5 minutes on the entire NYSE. This pulls everything from current price, to earnings dates, to p/e, among other metrics. I'm now trying to set up a cronjob to run a little python code to clean up the csv data before I import it into the mySQL database. Before I can set up the cronjob, I need to get the python code working... Baby steps :). I went away from python a few years ago, but am trying to use it again here. After some research, it's been

How to use while read line with tail -n

我的梦境 提交于 2020-04-11 07:15:08
问题 Problem: I have a CSV dump file - with excess of 250,000 lines. When I use while read - it takes a while (no pun intended). I would like to go back to the last 10,000 lines to do what I need to do instead of the 250,000 lines. Code Snippet: My current code is this: IFS="," while read line do awk_var=`echo "$line" | awk -F" " '{print $0}'` var_array=($awk_var) read -a var_array <<< "${awk_var}" echo "${var_array[1]}" done </some_directory/directory/file_in_question.csv Question: How can I use