[R] Mysterious issues with reading text files from R in ArcGIS and Excel

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Mar 4 18:29:00 CET 2013


Your description of diagnosis uses non-R software (off topic here). Please either describe the difference in the files (you may need a hex editor or the hexbin package to detect the differences) or supply the files that behave differently (this may require some alternate route than this mailing list if there are odd characters at fault).

For what it is worth, TXT is not a clearly-defined format, so this could be more effectively addressed by using a more specific format for data exchange.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Kerry <kernicholson at yahoo.com> wrote:

>I realize my command code is not writing a CSV file, I already pointed
>out that CSV file seems to work OK but not in the TXT format.
>�Regardless of that, there should be no problems in ArcGIS in reading
>the date column - in ArcGIS it will simply recognize it as a text field
>by default. �As I said in my initial posting, when I use other programs
>to create a text file (say textpad,wordpad, notepad or excel) and bring
>the txt file into ArcGIS, there is no dropping of the information - it
>doesn't turn the column into NA's. �It only does this when I try to add
>text files that were generated from using the write.table or write.csv.
>
>Any thoughts at to explain why I get 2 new columns of data in either
>the CSV format or the TXT format?
>>~K
>
>
>
>
>________________________________
>
>On 04/03/2013 10:52 AM, Kerry wrote:
>> Here's the first 5 lines of my dataset:
>> 
>> structure(list(id = structure(c(1L, 1L, 1L, 1L, 1L), .Label =
>c("F07001",
>> "F07002", "F07003", "F07004", "F07005", "F07006", "F07008", "F07009",
>> "F07010", "F07011", "F07014", "F07015", "F07017", "F07018", "F07019",
>> "F07020", "F07021", "F07022", "F07023", "F07024", "F10001", "F10002",
>> "F10004", "F10008", "F10009", "F10010", "F10012", "F10013", "F10014",
>> "F98015", "M07007", "M07012", "M07013", "M07016", "M10007", "M10011",
>> "M10015"), class = "factor"), x = c(1482445L, 1481274L, 1481279L,
>> 1481271L, 1480849L), y = c(6621768L, 6619628L, 6619630L, 6619700L,
>> 6620321L), date = structure(c(1173085253, 1173092441, 1173099672,
>> 1173106839, 1173114055), class = c("POSIXct", "POSIXt"), tzone = ""),
>>� �  R1dmed = c(2498.29727014221, 657.102921923195, 660.356911071581,
>>� �  620.139702002702, 378.186792471657), R1dmean =
>c(2498.29727014221,
>>� �  657.102921923195, 660.356911071581, 620.139702002702,
>378.186792471657
>>� �  ), R1error = c(FALSE, FALSE, FALSE, FALSE, FALSE), R2error =
>c(FALSE,
>>� �  FALSE, FALSE, FALSE, FALSE)), .Names = c("id", "x", "y",
>> "date", "R1dmed", "R1dmean", "R1error", "R2error"), row.names = c(NA,
>> 5L), class = "data.frame")
>> 
>> and here's the code I wrote for this file:
>> 
>> write.table(test, "D:/MooseEncounters/locations/Individual/test.txt")
>
>That's not a CSV file, it is being written with a blank as separator.� 
>Since it also has blanks in the formatted POSIXct column, you're very
>likely to run into problems reading it.
>
>Use write.csv(test, "test.csv") and you'll have fewer problems.� If you
>want tab-delimited columns instead, you'll need to specify that in the
>write.table call.
>
>Duncan Murdoch
>	[[alternative HTML version deleted]]
>
>
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list