Question

I have the following file, which i want to import.

                   MONTHLY CLIMATOLOGICAL SUMMARY for MAR. 2014

NAME: larissa   CITY:    STATE:  
ELEV:    82 m  LAT:  39° 37' 39" N  LONG:  22° 23' 55" E

                   TEMPERATURE (°C), RAIN  (mm), WIND SPEED (km/hr)

                                      HEAT  COOL        AVG
    MEAN                              DEG   DEG         WIND                 DOM
DAY TEMP  HIGH   TIME   LOW    TIME   DAYS  DAYS  RAIN  SPEED HIGH   TIME    DIR
------------------------------------------------------------------------------------
 1   9.7  11.3   15:50   7.6    7:20   8.6   0.0   5.4   1.3  12.9   20:10   NNE
 2  11.8  16.9   14:50   9.8   00:00   6.5   0.0   4.2   2.7  24.1   13:30    NE
 3   9.3  11.5   14:20   7.9   00:00   9.0   0.0   6.0   0.8   9.7    3:00     N
 4  10.7  17.0   15:10   4.7    6:30   7.7   0.0   1.6   0.6  16.1   18:50    SW
 5  11.1  18.5   14:40   6.0    7:30   7.3   0.0   0.2   1.1  16.1   18:50   SSW
 6  10.9  16.9   13:50   5.1    6:30   7.4   0.0   0.0   1.1  16.1   16:20   ENE
 7  11.3  13.8   14:20  10.1    9:00   7.1   0.0   7.0   3.9  25.7    4:20   NNE
 8  12.1  16.6   14:00   9.4    8:00   6.2   0.0   2.8   1.8  22.5   22:40   ENE
 9   9.0  10.4   13:10   7.6   00:00   9.3   0.0   0.4   1.8  27.4   10:40   NNE
10   7.9  10.1   13:50   6.6   23:50  10.4   0.0   1.0   4.0  24.1   20:20    NE
11   7.8  10.1   14:20   5.4    5:30  10.6   0.0   0.8   1.1  16.1   11:00     N
12  11.3  18.7   15:30   6.8    7:10   7.0   0.0   0.0   1.3  20.9   14:20    SW
13  11.3  19.1   16:00   4.5    7:40   7.1   0.1   0.0   0.6  12.9   13:10   WSW
14  11.7  20.1   15:40   5.1    6:30   6.8   0.2   0.0   0.6  11.3   15:00   WNW
15  12.6  21.1   15:40   5.2    7:10   6.1   0.3   0.0   0.5   9.7   14:10   SSW
16  14.6  22.3   15:40   8.3    7:10   4.4   0.7   0.0   1.1  11.3   10:40   ENE
17  15.0  24.3   15:10   7.1    6:10   4.6   1.3   0.0   1.0  12.9    7:10   ENE
18  16.0  26.9   15:40   7.2    6:40   4.2   1.9   0.0   0.6  11.3   15:00   SSE
19  17.7  28.4   15:10   8.2    6:50   3.3   2.7   0.0   1.8  24.1   23:40    SW
20  16.6  22.5   16:00  11.1   00:00   2.6   0.8   0.0   2.7  24.1    7:50     N
21  13.8  21.9   16:30   6.7    6:20   5.0   0.6   0.0   0.8  16.1   14:50   ENE
22  14.3  24.1   15:40   5.8    5:40   4.9   0.9   0.0   0.5   9.7   13:50    SW
23  16.4  25.7   16:00   9.8    7:40   3.5   1.6   0.0   0.5   9.7   13:30   ESE
24  16.3  24.9   14:50  10.2    6:10   3.2   1.1   0.0   2.4  29.0   16:10   SSW
25  14.1  21.0   15:40   9.2    6:40   4.5   0.3   0.0   3.9  32.2   14:50    SW
26  12.9  19.0   16:20   9.6    6:10   5.4   0.0   1.6   1.0  12.9   12:50     N
27  14.3  19.2   13:50  11.3    2:30   4.1   0.1   0.2   3.2  33.8   14:20   ENE
28  13.1  19.0   15:40   7.4    6:30   5.3   0.0   0.4   1.4  17.7   15:50    SW
29  14.7  21.2   15:10  10.8    5:40   3.9   0.3   0.2   1.3  19.3   11:30   ENE
30  12.6  17.2   15:30   9.2   00:00   5.4   0.0   0.0   2.6  25.7    4:00   ENE
31  13.1  23.0   17:00   5.2    7:30   6.0   0.7   0.0   0.5   8.0   14:50    SW
-------------------------------------------------------------------------------------
    12.7  28.4    19     4.5    13   187.4  13.5  31.8   1.6  33.8    27     ENE

Max >=  32.0:  0
Max <=   0.0:  0
Min <=   0.0:  0
Min <= -18.0:  0
Max Rain: 7.01 ON 07/03/14
Days of Rain: 14 (> .2 mm) 5 (> 2 mm) 0 (> 20 mm)
Heat Base:  18.3  Cool Base:  18.3  Method: Integration

By simply trying to use read.table with header=T, dec=".", sep="" as additional arguments, i get this error:

Error in read.table("C:\\blablabla\\file.txt)
  more columns than column names
Execution halted

I think the file is not \t separated but rather "". I am also thinking this might be caused by the extra text before the table. Would read.csv make a difference?

Any suggestions? Thanks in advance.

Was it helpful?

Solution

The problem is the fact that there is some additional information listed above the column names. Simply skipping this will solve your issue. For this, you can use the skip parameter which is part of read.csv.

dat = read.csv('/path/to/file.csv', header = TRUE, dev = ".", sep = "", skip = 9)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top