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 8594293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:09:54+00:00 2026-06-12T00:09:54+00:00

I have a text data separated ny commas i.e.,. The sample of the data

  • 0

I have a text data separated ny “commas” i.e.”,”. The sample of the data is given below (first row indicates the column names):

userID,appName,startTime,endTime,endResult
chhieut,gms.mos.test,2012-07-01 02:47:16,2012-07-01 02:47:46,1
chhieut,gms.mos.test,2012-07-01 03:11:46,2012-07-01 03:12:25,2
chhieut,gms.mos.test,2012-07-01 03:13:36,2012-07-01 03:14:03,2
chhieut,gms.mos.test,2012-07-01 03:18:26,2012-07-01 03:18:58,2
chhieut,gms.mos.test,2012-07-01 04:10:36,2012-07-01 04:10:54,2
chhieut,gms.mos.test,2012-07-01 04:38:26,2012-07-01 04:38:48,2
chhieut,gms.mos.test,2012-07-01 04:48:56,2012-07-01 04:49:04,3
chhieut,gms.mos.test,2012-07-01 05:49:46,2012-07-01 05:50:14,2
chhieut,gms.mos.test,2012-07-01 06:19:07,2012-07-01 06:19:25,2
chhieut,gms.mos.test,2012-07-01 07:09:17,2012-07-01 07:09:47,2

I am using the following syntax:

appsession <- read.table("C:/.../AppSession.txt", sep = ",", 
  col.names = c("userID","appName","startTime","endTime","endResult"), 
  fill = FALSE, strip.white = TRUE)

I am getting this error:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 1 did not have 5 elements
  • 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-06-12T00:09:55+00:00Added an answer on June 12, 2026 at 12:09 am

    Using suitably edited version of your data (i.e. removing all the blank lines!), this can be loaded into R easily via read.csv(). Note here I’m using a text connection containing the data to avoid writing your data to a file. Just replace con with your file name in the read.csv().

    con <- textConnection("userID,appName,startTime,endTime,endResult
    chhieut,gms.mos.test,2012-07-01 02:47:16,2012-07-01 02:47:46,1
    chhieut,gms.mos.test,2012-07-01 03:11:46,2012-07-01 03:12:25,2
    chhieut,gms.mos.test,2012-07-01 03:13:36,2012-07-01 03:14:03,2
    chhieut,gms.mos.test,2012-07-01 03:18:26,2012-07-01 03:18:58,2
    chhieut,gms.mos.test,2012-07-01 04:10:36,2012-07-01 04:10:54,2
    chhieut,gms.mos.test,2012-07-01 04:38:26,2012-07-01 04:38:48,2
    chhieut,gms.mos.test,2012-07-01 04:48:56,2012-07-01 04:49:04,3
    chhieut,gms.mos.test,2012-07-01 05:49:46,2012-07-01 05:50:14,2
    chhieut,gms.mos.test,2012-07-01 06:19:07,2012-07-01 06:19:25,2
    chhieut,gms.mos.test,2012-07-01 07:09:17,2012-07-01 07:09:47,2
    ")
    
    dat <- read.csv(con,
                    colClasses = c(rep("character", 2), rep("POSIXct", 2),
                                   "numeric"))
    close(con) ## closing connection, not needed with a file
    

    Also note that by specifying the colclasses argument we tell R what the data are before reading them in which saves some formatting later, especially with the DateTime data. We can do this here because you have the DateTime variables stored in the correct format.

    R> head(dat)
       userID      appName           startTime             endTime endResult
    1 chhieut gms.mos.test 2012-07-01 02:47:16 2012-07-01 02:47:46         1
    2 chhieut gms.mos.test 2012-07-01 03:11:46 2012-07-01 03:12:25         2
    3 chhieut gms.mos.test 2012-07-01 03:13:36 2012-07-01 03:14:03         2
    4 chhieut gms.mos.test 2012-07-01 03:18:26 2012-07-01 03:18:58         2
    5 chhieut gms.mos.test 2012-07-01 04:10:36 2012-07-01 04:10:54         2
    6 chhieut gms.mos.test 2012-07-01 04:38:26 2012-07-01 04:38:48         2
    R> str(dat)
    'data.frame':   10 obs. of  5 variables:
     $ userID   : chr  "chhieut" "chhieut" "chhieut" "chhieut" ...
     $ appName  : chr  "gms.mos.test" "gms.mos.test" "gms.mos.test" "gms.mos.test" ...
     $ startTime: POSIXct, format: "2012-07-01 02:47:16" "2012-07-01 03:11:46" ...
     $ endTime  : POSIXct, format: "2012-07-01 02:47:46" "2012-07-01 03:12:25" ...
     $ endResult: num  1 2 2 2 2 2 3 2 2 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Text file that contains data separated with a comma , . How
I have a method that reads data from a comma separated text file and
If I have a column called 'Categories' with say science,maths,english in the row comma-separated
Using .NET I have a text file with comma separated data. One of the
Hi I have problem with fetching data from one column separated with comma, My
I am reading data files in text format using readLines . The first 'column'
I have some data in JSON format in a text file as below. I
I have a text file which contains data seperated by '|'. I need to
I have a text data file that I likely will read with readLines .
I have text files containing structured data (it is a proprietary format and not

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.