dvdscripter / ini Goto Github PK
View Code? Open in Web Editor NEWRepository for R package ini
Home Page: https://cran.r-project.org/package=ini
Repository for R package ini
Home Page: https://cran.r-project.org/package=ini
Some INI files exist in the world where initial few variables have no [section]. This lib's read.ini currently would end up with error object 'lastSection' not found
for those.
Simply adding lastSection <- "DEFAULT"
atop of read func would solve that. I think mostly this approach would be ok to write.ini creating such section when asked but it would be cleaner if that section is written first without bracketed header.
Making both changes would help to work with basic key=value
files without any sections too.
Many libs use "DEFAULT" for reading but writing implementation varies https://en.wikipedia.org/wiki/INI_file
Hello,
Thanks for this nice and straightforward package!
I'm wanting to parse an INI file generated by another tool and store any modifications afterwards. These files do not contain any sections, which read.ini
(and I guess write.ini
) don't really like.
The error in question is
Error in ini::read.ini("...") :
object 'lastSection' not found
Perhaps lastSection
could be initialized with a default dummy value?
(I guess for now a workaround would be to manually inject a dummy section prior to parsing the file and do the writing with another function.)
Regards,
Rick
When we call write.ini it adds space to the between key and value ,as a result if the ini file is parsed using INIParser in Java it would give error . if we add a space option like below it can be avoided
`write.ini <- function(x, filepath,spaceOption, encoding = getOption("encoding")) {
con <- file(filepath, open = 'w', encoding = encoding)
on.exit(close(con))
for(section in names(x) ) {
writeLines( paste0('[', section, ']'), con)
for (key in x[ section ]) {
if(spaceOption) {
writeLines( paste0(names(key), ' = ', key), con)
}else{
writeLines( paste0(names(key), '=', key), con)
}
}
writeLines("", con)
}
}`
Report from below comes from e-mail. Writing here to document!
library(ini)
iniFile <- tempfile(fileext = '.ini')
sink(iniFile)
cat("; This line is a comment\n")
cat("# This one too!\n")
cat("[Hello World]\n")
cat("Foo1 = Bar=345 \n")
cat("Foo2 = Bar=345 \n")
cat("Foo3 = Bar\=345 \n")
sink()
checkini <- read.ini(iniFile)
checkini
checkini
#> Error: '=' is an unrecognized escape in character string starting ""Foo2 = Bar="
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.