csv

Operations on a very large csv with pandas

試著忘記壹切 提交于 2020-11-30 01:41:05
问题 I have been using pandas on csv files to get some values out of them. My data looks like this: "A",23.495,41.995,"this is a sentence with some words" "B",52.243,0.118,"More text but contains WORD1" "A",119.142,-58.289,"Also contains WORD1" "B",423.2535,292.3958,"Doesn't contain anything of interest" "C",12.413,18.494,"This string contains WORD2" I have a simple script to read the csv and create the frequencies of WORD by group so the output is like: group freqW1 freqW2 A 1 0 B 1 0 C 0 1 Then

Operations on a very large csv with pandas

人走茶凉 提交于 2020-11-30 01:40:25
问题 I have been using pandas on csv files to get some values out of them. My data looks like this: "A",23.495,41.995,"this is a sentence with some words" "B",52.243,0.118,"More text but contains WORD1" "A",119.142,-58.289,"Also contains WORD1" "B",423.2535,292.3958,"Doesn't contain anything of interest" "C",12.413,18.494,"This string contains WORD2" I have a simple script to read the csv and create the frequencies of WORD by group so the output is like: group freqW1 freqW2 A 1 0 B 1 0 C 0 1 Then

Unicode Encode Error 'latin-1' codec can't encode character '\u2019'

人走茶凉 提交于 2020-11-30 00:24:24
问题 I am trying to create a CSV of data from a MySQL RDB to move it over to Amazon Redshift. However, one of the fields contains descriptions and some of those descriptions contain the '’' character, or the right single quotation mark. before when I would run the code, it would give me UnicodeEncodeError: 'charmap' codec can't encode character '\x92' in position 62: character maps to <undefined> I then tried using REPLACE to attempt to get rid of the right single quotation marks. db = pymysql

Java code to import CSV into Access

一曲冷凌霜 提交于 2020-11-30 00:17:06
问题 I posted the code below to the Sun developers forum since I thought it was erroring (the true error was before this code was even hit). One of the responses I got said it would not work and to throw it away. But it is actually working. It might not be the best code (I am new to Java) but is there something inherently "wrong" with it? ============= CODE: private static void ImportFromCsvToAccessTable(String mdbFilePath, String accessTableName , String csvDirPath , String csvFileName ) throws

Java code to import CSV into Access

南笙酒味 提交于 2020-11-30 00:16:05
问题 I posted the code below to the Sun developers forum since I thought it was erroring (the true error was before this code was even hit). One of the responses I got said it would not work and to throw it away. But it is actually working. It might not be the best code (I am new to Java) but is there something inherently "wrong" with it? ============= CODE: private static void ImportFromCsvToAccessTable(String mdbFilePath, String accessTableName , String csvDirPath , String csvFileName ) throws

Can python's csv reader leave the quotes in?

孤人 提交于 2020-11-29 04:39:53
问题 I want to use the python CSV reader but I want to leave the quotes in. That is I want: >>> s = '"simple|split"|test' >>> reader = csv.reader([s], delimiter='|', skipinitialspace=True) >>> reader.next() ['"simple|split"', 'test'] But I actually get: ['simple|split', 'test'] In my case I want the quoted string to be passed on still quoted. I know the CSV reader is working as intended and my use case is an abuse of it, but is there some way to bend it to my will? Or do I have to write my own

Can python's csv reader leave the quotes in?

允我心安 提交于 2020-11-29 04:38:45
问题 I want to use the python CSV reader but I want to leave the quotes in. That is I want: >>> s = '"simple|split"|test' >>> reader = csv.reader([s], delimiter='|', skipinitialspace=True) >>> reader.next() ['"simple|split"', 'test'] But I actually get: ['simple|split', 'test'] In my case I want the quoted string to be passed on still quoted. I know the CSV reader is working as intended and my use case is an abuse of it, but is there some way to bend it to my will? Or do I have to write my own

Why Jupyter can't read the .csv file?

我的梦境 提交于 2020-11-29 03:51:24
问题 I'm using python 3 in jupyter notebook. The problem is that it can't read the csv file. The command to read the csv file i have used is: import pandas as pd df = pd.read_csv("py.csv") df I have tried a lot of other ways too, but every time it says that , file is not found although the csv file in my pc. FileNotFoundError Traceback (most recent call last) <ipython-input-4-cc06427474dd> in <module>() 1 import pandas as pd 2 ----> 3 df = pd.read_csv("py.csv") 4 df ~/anaconda/lib/python3.6/site

How to clean CSV file for a coordinate system using pandas?

青春壹個敷衍的年華 提交于 2020-11-25 04:12:00
问题 I wanted to create a program to convert CSV files to DXF(AutoCAD), but the CSV file sometimes comes with a header and sometimes no and there are cells that cannot be empty such as coordinates, and I also noticed that after excluding some of the inputs the value is nan or NaN and it was necessary to get rid of them so I offer you my answer and please share your opinions to implement a better method. sample input output 回答1: solution import string import pandas def pandas_clean_csv(csv_file): "

How to clean CSV file for a coordinate system using pandas?

孤者浪人 提交于 2020-11-25 04:09:39
问题 I wanted to create a program to convert CSV files to DXF(AutoCAD), but the CSV file sometimes comes with a header and sometimes no and there are cells that cannot be empty such as coordinates, and I also noticed that after excluding some of the inputs the value is nan or NaN and it was necessary to get rid of them so I offer you my answer and please share your opinions to implement a better method. sample input output 回答1: solution import string import pandas def pandas_clean_csv(csv_file): "