I have a number of large data files from which I want to extract data and output the extracted data as the corresponding csv files.
I use the following code (in a function) to do this work ...
A <- read.table(file=InputFile,
skip=36, sep="\t", header=TRUE,
quote="\"",stringsAsFactors=FALSE)
write.csv(A,file=OutputFile, row.names=FALSE)
Which works fine, except ... the header line in the data (line 37) has one extra tab. This means that I have to open the file in notepad (or similar) and remove the tab before I can apply the function.
Does anyone have any code that will remove this extra tab?
To add some clarity here is an example of what the file looks like ...
lines of data to be skipped
apples\toranges\tgrapes\t
1\t3\t5
2\t8\t3
... and here is what I want it to look like
lines of data to be skipped
apples\toranges\tgrapes
1\t3\t5
2\t8\t3
where \t represents a tab in the file and noting the extra tab in what becomes the header line after applying my code to the modified data.