Questions tagged [read.csv]

The command in R to read a data file with a “comma separated values” (csv) format.

The read.csv is a command in R to read a data file with a “comma separated values” (csv) format.

737 questions
4
votes
1 answer

Pandas pd.melt throwing memory error on unpivoting 3.5 GB csv while using 500GB ram

Pandas pd.melt throwing memory error on unpivoting 3.5 GB csv while using 500GB ram. Is there any solution/function available to unpivot gigantic CSV files?. The current csv has more then 5000 columns.
4
votes
1 answer

Extra commas at end of lines causing error with read.csv and read.table

I am trying to read this .csv file into R. When I use read.csv, I either get errors related to row.names, or the column names are offset from their original columns. Based on this post I believe the problem is related to having an extra comma at the…
Josh
  • 1,210
  • 12
  • 30
4
votes
2 answers

How to read csv with values containing commas in R?

I have a tool (exe provided to me), which outputs poorly formatted csv's. They are bad in that the last value can have commas, with no quotes, e.g.: 184500,OBJECT_CALENDAR,,,UNITS_NO_UNITS,NULL,,,,Sched N&S B1,1st,3rd,4S,5th&6th Where the last…
lukehawk
  • 1,423
  • 3
  • 22
  • 48
4
votes
1 answer

reading comma-separated strings with read.csv()

I am trying to load a comma-delimited data file that also has commas in one of its text columns. The following sample code generates such a file'test.csv',which I'll load usingread.csv()to illustrate my problem. > d <- data.frame(name = c("John…
Manojit
  • 611
  • 1
  • 8
  • 18
4
votes
1 answer

Constantly scanning for new files in R working directory

Is there a way to make R continuously scan the working directory for new files (in this case, CSVs), and whenever it finds a new file has been added to the working directory, to read it and perform some (always the same) task on it, and then go back…
4
votes
3 answers

R read.csv data from inline string with a csv file content

this is supposed to be a trivial thing, but I have not found anything googling it. I have the following data in a csv file test.csv var1,var2 'a',1 'b',2 which I read into R with d <- read.csv('test.csv') This there a way for me to insert the…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
4
votes
2 answers

Column names shift to left on read.table or read.csv

Originally I have this TSV file (sample): name type qty cxfm 1C 0 d2 H50 2 g3g 1G 2 hb E37 1 nlx E45 4 so I am using read.csv to read data from a .tsv file but I always get this output: name type qty 1…
Chayma Atallah
  • 725
  • 2
  • 13
  • 30
4
votes
2 answers

Parse currency values from CSV, convert numerical suffixes for Million and Billion

I'm curious if there's any sort of out of the box functions in R that can handle this. I have a CSV file that I am reading into a data frame using read.csv. One of the columns in the CSV contains currency values in the format of…
user3246693
  • 679
  • 11
  • 22
4
votes
1 answer

R: reading in a .csv turns all "" (blank spaces) to NA

I have a data set in which I converted all "~" values to blank spaces "", and when I use the View() function to view the data set, I can clearly see the blank spaces. However, after I save my modified data frame as a .csv file via write.csv and read…
user3755880
  • 375
  • 1
  • 5
  • 14
4
votes
2 answers

read.table() error, even though all elements are present

I'm getting an error with read.table(): data <- read.table(file, header=T, stringsAsFactors=F, sep="@") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 160 did not have 28 elements I checked line 160, and it…
user3821273
  • 151
  • 1
  • 3
  • 9
4
votes
1 answer

datatable.integer64 argument is not working for me should it?

I am trying to load integer64 as character in fread ?fread indicates that the integer64 argument is not implemented but the options(datatable.integer64) is. Though fread keeps loading as int64. How can I tell fread to load as character. EDIT [If…
statquant
  • 13,672
  • 21
  • 91
  • 162
4
votes
2 answers

R's read.csv() omitting rows

In R, I'm trying to read in a basic CSV file of about 42,900 rows (confirmed by Unix's wc -l). The relevant code is vecs <- read.csv("feature_vectors.txt", header=FALSE, nrows=50000) where nrows is a slight overestimate because why not. However, >>…
Cardano
  • 931
  • 1
  • 8
  • 14
3
votes
1 answer

Regex to insert new line \n at specific point in long text string file

I have text file of csv data running into 100s of thousands of what should be separate records but they forgot to put new lines into it. There is a repeated pattern to pick out where the start of a new line should be though, before a time, a comma,…
Skeiff
  • 31
  • 4
3
votes
1 answer

Why can R's read.csv() read a CSV from GitLab URL when pandas' read_csv() can't?

I noticed that panda's read_csv() fails at reading a public CSV file hosted on GitLab: import pandas as pd df = pd.read_csv("https://gitlab.com/stragu/DSH/-/raw/master/Python/pandas/spi.csv") The error I get (truncated): HTTPError …
stragu
  • 1,051
  • 9
  • 15
3
votes
3 answers

How do read file by filtering rows based on a condition in R

I am using R to reach csv. But i do not want whole dataset in memory as dataset is too large. But I need to read rows based on one column's category. I want to read only rows where col2 = 'A' Example : col1 col2 col 3 1 A 1000 2 …
Anuj Gupta
  • 37
  • 1
  • 4