csv

How to parse tsv file with python?

梦想的初衷 提交于 2020-08-19 04:33:12
问题 I have a tsv file which includes some newline data. 111 222 333 "aaa" 444 555 666 "bb b" Here b on the third line is a newline character of bb on the second line, so they are one data: The fourth value of first line: aaa The fourth value of second line: bb b If I use Ctrl+C and Ctrl+V paste to a excel file, it works well. But if I want to import the file using python, how to parse? I have tried: lines = [line.rstrip() for line in open(file.tsv)] for i in range(len(lines)): value = re.split(r'

How do I combine large csv files in python?

时间秒杀一切 提交于 2020-08-10 23:40:30
问题 I have 18 csv files, each is approximately 1.6Gb and each contain approximately 12 million rows. Each file represents one years' worth of data. I need to combine all of these files, extract data for certain geographies, and then analyse the time series. What is the best way to do this? I have tired using pd.read_csv but i hit a memory limit. I have tried including a chunk size argument but this gives me a TextFileReader object and I don't know how to combine these to make a dataframe. I have

Exporting tables to csv changes file extension

て烟熏妆下的殇ゞ 提交于 2020-08-10 19:21:36
问题 I'm trying to export all my tables, from my access database, to separate .csv-files. I have a loop that runs through all tables and by using TransferText I want to create a .csv-file for each table. I am able to create a single file by writing the TransferText method. DoCmd.TransferText acExportDelim, "ExportCsv", [Table name], filePath + "Test.csv", True But when I'm trying to create a loop to generate a file for each table I get into trouble. (Filepath is set to desktop) ' Loops through all

How to improve the speed of insertion of the csv data in a database in php?

爱⌒轻易说出口 提交于 2020-08-10 18:59:12
问题 I wrote this code that allows to read a folder, depending on the file name is inserted in a different table the data of the csv file. Once the file is processed it is moved to another folder. My code works well but the second csv file is more than 80 000 lines long and it takes several hours to be integrated in my database. How can I improve the performance of my code? I tried 'LOAD DATA LOCAL' but without success... <?php include("../connexion.php"); ini_set('max_execution_time', 54000);

How to handle commas in the data of a csv in Java

蓝咒 提交于 2020-08-09 12:56:16
问题 I'm using scanner.delimiter to split my csv, with the delimiter being ",". However I have some data that includes commas in the data like "Monsters, Inc." However if I set the delimiter to "\",\"", then it crashes on everything else. Ideas that don't require me to write my own scanner.delimiter method? 回答1: I don't think scanner.delimiter will work for this kind of problem. If you have quotes in the data where the extra comas exist, you can either use a regular expression or code to solve

Check if a group exists in AD using PowerShell

淺唱寂寞╮ 提交于 2020-08-09 09:00:08
问题 I wanted to create the code for the group to check whether the group exist or not exist. However, I couldn't get to work as it was successful adding the user and part members of the group only one but not the other groups because I manage to create a group in active directory and also reading from the csv. Here is my code and the result. Seems I get the error always after it successfully adding the user and including adding the members of the group Result #Import required modules Import

Convert XLS file to CSV but error number cell

北城余情 提交于 2020-08-08 07:05:35
问题 The following code allows you to convert a file from an XLS to a CSV : static void ConvertExcelToCsv(string excelFile, string csvOutputFile, int worksheetNumber = 1) { //Checks if the two files required exist or not and then throws an exception. if (!File.Exists(excelFile)) throw new FileNotFoundException(excelFile); if (File.Exists(csvOutputFile)) { File.Delete(csvOutputFile); } // connection string var cnnStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended

Convert XLS file to CSV but error number cell

痞子三分冷 提交于 2020-08-08 07:04:42
问题 The following code allows you to convert a file from an XLS to a CSV : static void ConvertExcelToCsv(string excelFile, string csvOutputFile, int worksheetNumber = 1) { //Checks if the two files required exist or not and then throws an exception. if (!File.Exists(excelFile)) throw new FileNotFoundException(excelFile); if (File.Exists(csvOutputFile)) { File.Delete(csvOutputFile); } // connection string var cnnStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended

Reading a .por dataset into R from google drive

可紊 提交于 2020-08-06 05:14:41
问题 Following this answer, I'm trying to read a .por file into R via a shareable link (https://drive.google.com/file/d/124WOY4iBXxv_9eBXsoHJVUzX98x2sxYy/view?usp=sharing) without success (using haven package): Error in df_parse_por_file(spec, encoding = "", user_na = user_na, cols_skip Is this fixable? Tried the following: library(haven) id <- '124WOY4iBXxv_9eBXsoHJVUzX98x2sxYy' j <- sprintf("https://docs.google.com/uc?id=%s&export=download", id) dta <- haven::read_por(j) 回答1: You could use

data frame with commas as decimal separator

。_饼干妹妹 提交于 2020-08-06 05:04:48
问题 I have data frame as csv file, numbers are separated with commas as decimal separators, I managed to import and read it in R using read.csv2 . But now numbers are seen as characters . What I want to do is to replace commas with dots and have a numeric value. My df looks like this: var1 <- c("50,0", "72,0", "960,0", "1.920,0", "50,0", "50,0", "960,0") var2 <- c("40,0", "742,0", "9460,0", "1.920,0", "50,0", "50,0", "960,0") var3<- c("40,0", "72,0", "90,0", "1,30", "50,0", "50,0", "960,0") df <-