0

How can I import data-set of CSV file, in which Urdu is written? I trying to do in this way, but getting error. Am I doing something wrong?

Code:

library(rio)
Sys.setlocale("LC_ALL","Urdu") 
fil <- read.csv("D:/PycharmProjects/shiny-examples-master/shiny-examples-master/Data_set.csv",encoding='UTF-8')

Data_set.csv:

Reg No.     address
13  Nazim ud Din Road, F-11, ICT,  دارالحکومت اسلام آباد, 44000, ‏پاکستان‎
45  Street 34, F-7/1, F-7, ICT, دارالحکومت اسلام آباد, 44000, ‏پاکستان‎
5564    Lane 11, DHA Phase II, ICT,  دارالحکومت اسلام آباد, 44000, ‏پاکستان

Error:

Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 2 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 3 appears to contain embedded nulls
4: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 4 appears to contain embedded nulls
5: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 5 appears to contain embedded nulls
6: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  incomplete final line found by readTableHeader on 'D:/PycharmProjects/shiny-examples-master/shiny-examples-master/12000.csv'
Knowledge Seeker
  • 526
  • 7
  • 25

1 Answers1

1

Try using the skipNul flag and see if that works.

read.csv("Data_set.csv", header = TRUE, sep="\t", encoding="UTF-8", skipNul = TRUE)

                                                           Reg.No......address
1    13  Nazim ud Din Road, F-11, ICT,  دارالحکومت اسلام آباد, 44000, ‏پاکستان‎
2       45  Street 34, F-7/1, F-7, ICT, دارالحکومت اسلام آباد, 44000, ‏پاکستان‎
3  5564    Lane 11, DHA Phase II, ICT,  دارالحکومت اسلام آباد, 44000, ‏پاکستان

Or set encoding to UTF-16E, but UTF-8 looks right.

read.csv("test.csv", header = TRUE, sep="\t", encoding="UTF-16E", skipNul = TRUE)
                                                                                   Reg.No......address
1 13  Nazim ud Din Road, F-11, ICT,  ط¯ط§ط±ط§ظ„ط­ع©ظˆظ…طھ ط§ط³ظ„ط§ظ… ط¢ط¨ط§ط¯, 44000, â€ڈظ¾ط§ع©ط³طھط§ظ†â€ژ
2    45  Street 34, F-7/1, F-7, ICT, ط¯ط§ط±ط§ظ„ط­ع©ظˆظ…طھ ط§ط³ظ„ط§ظ… ط¢ط¨ط§ط¯, 44000, â€ڈظ¾ط§ع©ط³طھط§ظ†â€ژ
3  5564    Lane 11, DHA Phase II, ICT,  ط¯ط§ط±ط§ظ„ط­ع©ظˆظ…طھ ط§ط³ظ„ط§ظ… ط¢ط¨ط§ط¯, 44000, â€ڈظ¾ط§ع©ط³طھط§ظ†
Anonymous coward
  • 2,061
  • 1
  • 16
  • 29