There was a typo, each row should have 5 columns.
I tried to read the .csv file and write it as a .dat file, but have some problems.
require(readr)
DF = read_csv(originaldata.csv, col_names=F, col_types=list(col_character(),
col_double(), col_double(), col_double(), col_double()))
write.table(DF, "reformatdata.dat", col.names=F, row.names=F, fileEncoding='UTF-8')
But how to leave the required space as I mentioned above? I put the requirements below:
The first column represents ID, and are five characters. The second and third columns represent latitude and longitude, where they each should be 8 floating point numbers with two decimals. The next 2 columns represent values, and they each have 10 floating points number with two decimals. For example, if the last column in the first row has 7 floating points in total, there should be 3 empty spaces before the number. So that each row has ordered numbers. Thanks again for your help.