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

  • Home
  • SEARCH
  • 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 3340254
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:35:11+00:00 2026-05-18T00:35:11+00:00

This is the data file: ID YR MO DA YrM MoM DaM 100 2010

  • 0

This is the data file:

ID  YR  MO  DA  YrM  MoM  DaM  
100  2010  2  20  2010  8  30  
110  2010  4  30  2010  9  12     
112  2010  8  20  2010  10  28  

I should be able to access each element in this file, i tried to use this function in creating record in Mathematica but i am getting a error

ReadList["testA.txt", Number, RecordLists -> true]

Error: ReadList::opttf: Value of option RecordLists -> true should be True or False.

Also how do I access each element after doing the records?

Also is there a way in Mathematica to create one more column which does difference between two dates and put it in new column.

This homework assignment does allow to use excel to compute, but i have to do this in Mathematica.

  • 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-18T00:35:12+00:00Added an answer on May 18, 2026 at 12:35 am

    You’ve asked 3 questions, and I’ll try to answer them all. As belisarius pointed out, Mathematica is case sensitive. So, your code should be:

    In[1]:=ReadList["testA.txt", Number, RecordLists -> True]
    

    However, this will still generate an error as your first line is made up of Strings not Numbers. So, the simplest thing to do is to go with Michael Pilat’s solution and use Import. This returns a list of lists where each record in the file becomes one of the sublists.

    To access a specific sublist, you use Part, or its simpler form [[ ]], as follows:

    In[2]:={{100, 2010, 2, 20, 2010, 8, 30}, 
            {110, 2010, 4, 30, 2010, 9,12}, 
            {112, 2010, 8, 20, 2010, 10, 28}}[[1]]
    Out[2]:={100, 2010, 2, 20, 2010, 8, 30}
    

    Or, if you want a specific column

    In[3]:={{100, 2010, 2, 20, 2010, 8, 30}, 
            {110, 2010, 4, 30, 2010, 9,12}, 
            {112, 2010, 8, 20, 2010, 10, 28}}[[All,4]]
    Out[3]:={20, 30, 20}
    

    Now, to add another column to your list, there are a couple of ways. The simplest way is to Transpose your data,

    In[4]:=Transpose[data]
    Out[4]:={{100, 110, 112}, {2010, 2010, 2010}, {2, 4, 8}, 
             {20, 30, 20}, {2010, 2010, 2010}, {8, 9, 10}, {30, 12, 28}}
    

    select the now rows and Apply the function to them,

    In[5]:=Plus @@ Out[4][[{3,6}]]
    Out[5]:={10,13,18}
    

    attach the new row to the old data, and transpose back

    In[6]:=Out[4]~Join~Out[5] // Transpose
    Out[6]:={100, 2010, 2, 20, 2010, 8, 30, 10}, 
            {110, 2010, 4, 30, 2010, 9, 12, 13}, 
            {112, 2010, 8, 20, 2010, 10, 28, 18}}
    

    A conceptually more difficult, but more straightforward method is to use Map to apply a function to each row in the original data that returns the row with the new datum present

    In[7]:=Map[#~Join~{Plus@@#[[{3,6}]]}&, data]
    Out[7]:={100, 2010, 2, 20, 2010, 8, 30, 10}, 
            {110, 2010, 4, 30, 2010, 9, 12, 13}, 
            {112, 2010, 8, 20, 2010, 10, 28, 18}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating a file which contains data like this. 78,45,New things,200, Number of
I have a web service that queries data from this json file, but I
I'm probably doing this all wrong. I have a text file full of data
So I have been writing to Environment.SpecialFolder.ApplicationData this data file, that upon uninstall needs
I am using PHP to expose vehicle GPS data from a CSV file. This
I have a time series(a csv file) data that looks like below. Each observation
Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957
I can set data in JTable constructor, and then user can change this data
I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag]
I have a internal website that users log into. This data is saved as

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.