R input file arabic? - r

I am writing a program that reads arabic text from a text file in R, whenever i read the file i get the following errors:
Warning messages:
1: In read.table("C:\\Users\\Mustafa\\Desktop\\arabic.txt", sep = "\n", :
invalid input found on input connection 'C:\Users\Mustafa\Desktop\arabic.txt'
2: In read.table("C:\\Users\\Mustafa\\Desktop\\arabic.txt", sep = "\n", :
incomplete final line found by readTableHeader on 'C:\Users\Mustafa\Desktop\arabic.txt'
File<-read.table("C:\\Users\\Mustafa\\Desktop\\arabic.txt",sep=" \n",col.names="ar",fileEncoding="UTF-8")
I have no idea where error is , the environment i am using is windows, on mac os it works file, however i must run it on windows! any help is appreciated.
Thank you!

This error message means that your file does not end with EOL (end-of-line character) e.g. \n or \r\n.
This is sort of a warning that your file might not be completed. It seems that on MAC it is ignored, but in windows it is considered an error.
The solution is easy, just add a new line at the end of your file, save it and try again.

The below code worked for me.
Sys.setlocale("LC_ALL","Arabic")

Related

When I try to set up an array in python reading in data from a text file I am encountering a mysterious syntax error

When I run this piece of code I am getting a syntax error and I do not know what is wrong.
enter image description here
well, absorption = np.loadtxt('python test file.txt',
skiprows=3,
usecols=(1,7),
dtype={
'names': ('Well', 'Abs'),
'formats': ('U3', 'f4') ,
unpack = True)
Here is the code, I have already tried a closing } but it still gave me the same error

lesson containing non-ascii characters produces error when i try to run test in swirlify

It seems that swirlify can not handle non-ascii characters (like accented character). when trying to test or run the demo with test_lesson() or demo_lesson (), it causes a file read error.
1: In readLines(con) :
invalid input found on input connection '..../lesson.yaml'
2: In readLines(con) :
incomplete final line found on '..../lesson.yaml'
the error cames from the line
con <- file(input, encoding = "UTF-8")
of the yaml.load_file function
the solution is in R studio save the yaml file with save with encoding and choose UTF-8

'Incomplete final line' warning when trying to read gender.gmt file into R

I am trying to read all lines from the gmt file but I am always getting the same warning.
Here is the command and warning:
C <- readLines( file("~/gender.gmt") )
Warning message:
In readLines(file("~/gender.gmt")) :incomplete final line found on '~/gender.gmt'
I couldn't understand how to complete this incomplete line and what does it mean?
Here is some information I tried but of no help:
Incomplete final line when trying to read csv in R
Hope someone can help. Thank you.

Error in R. Error in gsub("(?<=\n)(?=.|\n)", continue, x, perl = TRUE) :

I am encountering an error in R that I cannot seem to figure out. I am creating an R markdown document where I read in an a csv table using this code.
iati <- read.csv(file="/filepath/IATI_NGOS.csv",head=TRUE,sep=",")
and then using ggplot2 I create a plot using the following code.
figure_one <- ggplot(iati, aes(iati$reporting.org))+
geom_bar(fill="blue")+
ylab("Total Activities")+
xlab("NGO Reporting Organizations in IATI")+
ggtitle("Total Number of Activities compared to each NGO Reporting Organization in IATI")+
coord_flip()
When I try to call figure_one in the R markdown I get the following error:
Quitting from lines 44-55 (NGO_IATI.Rmd)
Error in gsub("(?<=\n)(?=.|\n)", continue, x, perl = TRUE) :
input string 1 is invalid UTF-8
Calls: <Anonymous> ... paste -> comment_out -> line_prompt -> paste -> gsub
In addition: Warning message:
In grep("\n", message) : input string 1 is invalid in this locale
Execution halted
When I run this code in a regular R script I have absolutely no issues. I have search for some answers but can't figure it out.
Thanks!
I ended solving my issue by just doing a fresh install of R and Rstudio on my local machine. I think the recent update to Yosemite on my local environment created a lot of issues with the TeX plugin I had installed for R markdown.
I get the same question when I knit my rmarkdown document and find **encoding is the cause.
When you use functions like read.csv, fread or read_csv, you will read the column name.
If column names are in other languages, like Chinese, the problem will easily happen.
Or you rmarkdown works on Windows, but the encoding bug happens on Mac, a different environment.
The temporal solution is to rename the column name in English and resave the data files.
Here is the pseudocode in R to show my idea.
library(data.table)
library(tidyverse)
fread('yourfile.csv',encoding = 'UTF-8') %>%
purrr::set_names(c('x1','x2','x3')) %>%
write_excel_csv('yourfile_2.csv')
Here the new file yourfile_2.csv is fine to rmarkdown knit without encoding problems happening.

I get error when I use zip.au3 and console.au3 together in an autoit script

I get the following error when I use zip.au3 and console.au3 together. To simulate this error please create a new script in SciTE script editor and include zip.au3 and console.au3 and then run it (just two include lines are sufficient to simulate). You will get two pop up messages.
Here are the error messages:
First Popup message:
AutoIt Error:
Line 456 (File "C:\Program Files (z86)|AutoIt3\Include\zip.au3:):
$ZipFile=#ZipSplit[2]
$ZipFile=^Error
Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.
Second popup message:
Line 455 (File "C:\Program Files (z86)|AutoIt3\Include\Console.au3:):
If $_Amount_Startup_COnsole Then If^Error
Error: Variable used without being declared.
(I would like to attach zip.au3 and console.au3. How can I do it? They are available for download rom Autoit Forum - Example scripts)
Regards,
Nazir
As far as i can see, the Problem is that the Zip.au3 starts a function at startup which it should not do.
If you delete the first Lines in Zip.au3 then it should work fine:
If UBound($CMDLine) > 1 Then
If $CMDLine[1] <> "" Then _Zip_VirtualZipOpen()
EndIf
So my AutoIt dont gives back any Error Messages anymore. But I'm not sure if the other functions will work now. Try it out.
Teifun2
PS: sorry for my bad english!

Resources