Incorrect column name after loading csv - r

After loading csv, the name of the first column changed from "communityname" to "Êcommunityname".
crime=read.csv('crimedata.csv',check.names=FALSE)
Any one knows why and how to solve it?

Try to correct your Encoding. Try to use fileEncoding to correct it!

Related

How to handle date time formats using VAEX?

I am new to VAEX. Also I couldn't find any solution for my specific question in google. So I am asking here hoping someone can solve my issue :).
I am using VAEX to import data from CSV file in my DASH Plotly app and then want to convert Date column to datetime format within VAEX. It successfully imports the data from csv file. Here is how I imported data from csv into VAEX:
vaex_df=vaex.from_csv(link,convert=True,chunk_size=5_000)
Below it shows the type of the Date column after importing into VAEX. As you can see, it takes the Date column as string type.
Then when I try to change data type of Date columns with below code, it gives error:
vaex_df['Date']=vaex_df['Date'].astype('datetime64[ns]')
I dont know how to handle this issue, so I need your help. What am I doing wrong here?
Thanks in advance
The vaex.from_csv is basically an alias to pandas.read_csv. In pandas.read_csv there is an argument that use can use to specify which columns should be parsed as datetime. Just pass that very same argument to vaex.from_csv and you should be good to go!

Reading in file gives empty rows and columns

Given this CSV file:
How to read a file so that the extra commas that are not a part of data are excluded?
Seems that the file is ok. Have you tried the correct options for arguments in your importing function?
Would you like to try read_delim() from the readr package?

Informatica Cloud- Null character issue in from dat file

I am getting the following task error in Informatica Cloud.
FR_3085 ERROR: Row [1]: 2-th character is a null character, which is not allowed in a text input file d:\temp\psaas.csv.
How to fix this issue, I tried to use ReplaceStr(0, input, char(10), '') in the filter condition, but its still throwing me an error?
thanks
Bhavesh
What character set do you have set for the connector? You may need to set it to windows character or make sure your file is using UTF-8. Attaching the source file may help to understand the issue.
Your input file contains some invalid characters.
You can fix this issue by changing the file encoding.
Try to change the file encoding to "UTF-8" or "ANSI". Save the file and restart the job.

R not reading ampersand from .txt file with read.table() [duplicate]

I am trying to load a table to R with some of the column heading start with a number, i.e. 55353, 555xx, abvab, 77agg
I found after loading the files, all the headings that start with a number has a X before it, i.e. changed to X55353, X555xx, abvab, X77agg
What can I do to solve this problem. Please kindly notice that not all column heading are start with a number. What should I do to solve this problem?
Many thanks
Probably your issue will be solved by adding check.names=FALSE to your read.table() call.
For more information see ?read.table

How to export a csv in utf-8 format?

I am trying to export a data.frame to a csv with utf-8 encoding. I have tried generating the file with write.csv with no success and the help(write.csv) did not mention any specific advice on creating that specific output. Here is my current export line.
write.csv(prod_out, file="product_output.csv",append=FALSE,eol="\r")
Any advice you can offer is appreciated.
This question is pretty old - I guess things have changed a lot since 2010. Anyway, I just came across this post and I happen to know the solution. You just add fileEncoding = "UTF-8" option directly to write.csv.
Try opening a UTF8 connection:
con<-file('filename',encoding="UTF-8")
write.csv(...,file=con,...)
You can try this solution:
write.csv(data,"data.csv",fileEncoding = "UTF-8")

Resources