Question: I need to to read a .txt file from an URL, but would like to skip the rows until a row with a certain value. The URL is <https://fred.stlouisfed.org/data/HNOMFAQ027S.txt> and the data takes the following form:

"

... (number of rows) 

... (number of rows) 

... (number of rows) 

DATE VALUE

1945-01-01 144855

1946-01-01 138515

1947-01-01 136405

1948-01-01 135486

1949-01-01 142455

"

I would like to skip all rows until the row with "DATE // VALUE" and start importing the data from this line onwards (including "DATE // VALUE"). Is there a way to do this with data.table's fread() - or any other way, such as with dplyr?

Thank you very much in advance for your effort and your time! 

Best,

c.

Answer: 
Combining fread with unix tools:

```
> fread("curl -s https://fred.stlouisfed.org/data/HNOMFAQ027S.txt | sed -n -e '/^DATE.*VALUE/,$p'")
           DATE   VALUE
  1: 1945-10-01    1245
  2: 1946-01-01       .
  3: 1946-04-01       .
  4: 1946-07-01       .
  5: 1946-10-01    1298
 ---                   
282: 2016-01-01 6566888
283: 2016-04-01 6741075
284: 2016-07-01 7022321
285: 2016-10-01 6998898
286: 2017-01-01 7448792
> 

```
Using:

```
file.names <- c('https://fred.stlouisfed.org/data/HNOMFAQ027S.txt',
                'https://fred.stlouisfed.org/data/DGS10.txt',
                'https://fred.stlouisfed.org/data/A191RL1Q225SBEA.txt')

text.list <- lapply(file.names, readLines)
skip.rows <- sapply(text.list, grep, pattern = '^DATE\\s+VALUE') - 1

# option 1
l <- Map(function(x,y) read.table(text = x, skip = y), x = text.list, y = skip.rows)

# option 2
l <- lapply(seq_along(text.list), function(i) fread(file.names[i], skip = skip.rows[i]))

```

will get you a list of data.frame's (option 1) or data.table's (option 2).