I've got a folder with 500 newspaper articles. Each article is saved in a seperate file with a number in the title like "1.txt", "2.txt". Each article has a date but it is not clear in which line the date is printed. I would like to seperate the date from the article and put them in two columns. The purpose is that I can make selection of articles based on periods of time.
A article looks like this:
The Light of Truth ENORMOUS IPO MAKES THE BILLIONAIRE 2013/12/18 CENTRUM, Tethys - the president and PRESIDENT international Sten can add another description to its name:.......
fname = FileNameJoin[{"E:\\data\\MC1 Data\\MC1 Data\\articles\\",
"testfile3.txt"}];
s = OpenWrite[fname]
For[i = 1, i < 20, i++,
test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt","Text"];
test2 = {
StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};
WriteString[s, test2, "\n"];
]
When I open the file,
test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]
I will see this:
{{2013/12/18}, {the, light, of, truth, enormous, ipo, makes, the,
billionaire, of, sanjorge, centrum,}}
{2009/06/21}, {news, online, today, protest, turns, violent, in,
abila, abila, kronos, a, rally, of, hundreds, of, protestors, allied,
with, the, protectors, of, kronos, movement, turned, to, violence}
The structure of this file is like this :{{..},{..}} and I can't make a selection like
Select[file[All,{1,2}]], #[[1]]<"2009/06/21"&]
Anyone a suggestion how to solve this?