Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6959147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:14:04+00:00 2026-05-27T15:14:04+00:00

I am trying to read a CSV file in R (under linux) using read.csv().

  • 0

I am trying to read a CSV file in R (under linux) using read.csv(). After the function gets completed I find that the number of lines read in R is less than the number of lines in CSV file (obtained by wc -l). Also, every time I read that specific CSV file always the same lines are getting skipped. I checked the formatting errors in CSV file but everything looks good.

But if I extract the lines being skipped into another CSV file, then R is able to read very lines from that file.

I am not able to find anywhere what my problem could be. Any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:14:04+00:00Added an answer on May 27, 2026 at 3:14 pm

    Here’s an example of using count.fields to determine where to look and perhaps apply fixes. You have a modest number of lines that are 23 ‘fields’ in width:

    > table(count.fields("~/Downloads/bugs.csv", quote="", sep=","))
         2     23     30 
       502     10 136532 
    > table(count.fields("~/Downloads/bugs.csv", sep=","))
    # Just wanted to see if removing quote-recognition would help.... It didn't.
         2      4     10     12     20     22     23     25     28     30 
     11308     24     20     33    642    251     10      2    170 124584 
    > which(count.fields("~/Downloads/bugs.csv", quote="", sep=",") == 23)
     [1] 104843 125158 127876 129734 130988 131456 132515 133048 136764
    [10] 136765
    

    I looked at the 23 with:

    txt <-readLines("~/Downloads/bugs.csv")[
                     which(count.fields("~/Downloads/bugs.csv", quote="", sep=",") == 23)]
    

    And they had octothorpes (“#”, hash-signs) which are comment characters in R data parlance.

    > table(count.fields("~/Downloads/bugs.csv", quote="", sep=",", comment.char=""))
        30 
    137044 
    

    So…. use those settings in read.table and you should be “good to go”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read a file using csv.DictReader I have a field that
I have a csv file that I am trying to read in R, for
I am trying to read a very simple but somehow large(800Mb) csv file using
To simplify, I'm trying to read the content of a CSV-file using the ifstream
I am trying to create a csv file using python that is truly Excel-compatible
I am trying to read in a CSV file that looks like this: ruby,2,100
I'm trying to read a CSV file generated by M$ Excel on linux. The
I'm trying to read into R a csv file that contains information on political
I'm using ruby 1.9.2 I'm trying to parse a CSV file that contains some
I am trying to read a CSV file with accented characters with Python (only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.