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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:02:35+00:00 2026-06-17T00:02:35+00:00

I’m trying to get some data from the federal reserve and paste into my

  • 0

I’m trying to get some data from the federal reserve and paste into my spreadsheet.

So here is my code

function myFunction() {
var response = UrlFetchApp.fetch("http://research.stlouisfed.org/fred2/data/TWEXMANL.txt");
a=response.getContentText();
var ss = SpreadsheetApp.getActiveSpreadsheet(); 
var InputSheet = ss.getSheetByName("Sheet5"); 
InputSheet.getRange("E5:E5").setValue(a); 
}

This code pastes all of the output into E5. I just want the data following the “Date” and “Value” pasted into 2 columns.

Can anybody help me with this? I’m sure it’s pretty simple for you guys.

Thanks.

  • 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-17T00:02:36+00:00Added an answer on June 17, 2026 at 12:02 am

    Using a little string manipulation, this becomes very easy:

    function myFunction() {
      var response = UrlFetchApp.fetch("http://research.stlouisfed.org/fred2/data/TWEXMANL.txt");
      a=response.getContentText();
      var ss = SpreadsheetApp.getActiveSpreadsheet(); 
      var InputSheet = ss.getSheetByName("Sheet1"); 
    
      //Slice off the text above the columns
      var allData = a.slice(a.indexOf("DATE         VALUE"));
    
      //Trim spaces between date and value to just 1 space for splitting
      allData = allData.replace(/ +/g, " ");
    
      //Split the text so each line is a row
      var splitData = allData.split("\n");
    
      //For some reason, there is an extra line, so remove it
      splitData.pop();
    
      //Split each row so data is one column and value is another
      for(var i = 0; i < splitData.length; i += 1) {
        splitData[i] = splitData[i].split(" ");
      }
    
      //Save to spreadsheet. +4 because you start at E5. Note the change to F on the right.
      InputSheet.getRange("E5:F" + (splitData.length + 4)).setValues(splitData);
    }
    

    I start by taking off the little intro text. I then split the string into an array containing the rows of data. I split each row (a string) into an array as well. This gives me a array I can use setValues() on at the bottom. Because this isn’t just one cell, I have to specific the exact width and height or it fails.

    If you’d like to see the data at any point in there, I recommend Logger.log(splitData);

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to construct a data frame in an Rcpp function, but when I
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
Basically, what I'm trying to create is a page of div tags, each has

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.