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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:33:02+00:00 2026-06-09T19:33:02+00:00

..I need to modify several CSV’s as follow’s… This is what I have: 2012-08-13

  • 0

..I need to modify several CSV’s as follow’s…

This is what I have:

2012-08-13 00:15:15; 768.548
2012-08-13 00:30:15; 768.625
2012-08-13 00:45:15; 768.667
2012-08-13 01:00:15; 768.729
2012-08-13 01:15:15; 768.785
2012-08-13 01:30:15; 768.827

But what I need for my analyses is this:

2012-08-13 00:15:15; xxx
2012-08-13 00:30:15; 0.077
2012-08-13 00:45:15; 0.042
2012-08-13 01:00:15; 0.062
2012-08-13 01:15:15; 0.056
2012-08-13 01:30:15; 0.042

What I need to do is subtract the actual line from the line above.

I’ve done some simple shell script’s which calculate the sum of those file’s but never did something that complex…

And there’s an extra challenge: the first line/value need’s to be subtracted by the value from the day before which is in another CSV.

Hope you can help

  • 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-09T19:33:03+00:00Added an answer on June 9, 2026 at 7:33 pm

    How about a little awk script?

    awk -F';' 'NR==1 {print $1 "; xxx"}; NR > 1 {print $1 "; " $2 - x} {x=$2}' < your_file.csv
    

    As for the first line (where it’s xxx at the moment), I’d write a little shell function:

    get_last_value()
    {
    ## first argument is the filename
        tail -n 1 $1 | cut -d';' -f2
    }
    

    and then modify the snippet above to

    awk -F';' 'NR==1 {print $1 "; " $2 - '$(get_last_value PREVIOUS)'}; NR > 1 {print $1 "; " $2 - x} {x=$2}' THIS_FILE
    

    and then all you need to do is obtain the combinations of PREVIOUS and THIS_FILE for each call. Also note that the very first file must be processed with the untweaked snippet above (as there is no previous value).

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

Sidebar

Related Questions

I need to modify an existing project. In this project there are several (many)
I need to modify a column in a SQLite database but I have to
I have several web sequential pages which will modify a record and its child
i have several CSS styles i would need to include in the JSP page,
I have several classes of a thirdparty component (which I cannot modify), Now I
I need for a project to modify UIImage. Here are steps I have to
I have a weird problem. I cannot modify the XML I need to work
I need to modify an existing script which uses SED to search and replace
I need to modify an MSI file, and I'd like to do it in
I need to modify the lm (or eventually loess ) function so I can

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.