Pino
November 26, 2022, 1:30pm
1
Hi,
I’m trying to write some code to import spreadsheets into julia, stack them together in an array, manipulate them a bit and save them into a csv.
I’m however having problems in importing programmatically the excel files as I get a ‘no node name’ error.
Location = pwd()
Directory = readdir(Location)
for ii in eachindex(Directory)
excel = XLSX.readxlsx(Directory[ii])
end
But I found that the following sort of works:
myexl=XLSX.openxlsx(Directory[1], enable_cache=false)
but then I don’t know how to make myexl into an array. So my question is why the no node error usinf readxlsx and other derivative xlsx functions?
What I can do better to achieve my task?
not sure where the error comes from but you can get the data by calling
myex.workbook.sheets[1][:]
Jake
February 8, 2023, 1:21am
3
Or if you want to use a DataFrame then
myexcel = DataFrame(XLSX.readtable(filename, sheet, Column))
I gave up with the function XLSX.readxlsx()
Here is my code snipped, for an excel file, where the first line with data starts at line number 4 and I know that in column one is the time and in column 2 the H2-flow:
fn_sel = "yourfilename.xlsx"
t_vec = Vector{Float64}(undef, 0)
ΦH2 = Vector{Float64}(undef, 0)
XLSX.openxlsx(fn_sel, enable_cache = false) do xf
name_sheet1 = XLSX.sheetnames(xf)[1]
sheet = xf[name_sheet1]
for i_sr in XLSX.eachrow(sheet) # sr = sheet raw
rownum = XLSX.row_number(i_sr)
if rownum > 3
# println("t: ", i_sr["A"], " s")
if ~isempty(i_sr["A"]) && ~isempty(i_sr["B"])
push!(t_vec, i_sr["A"])
push!(ΦH2, i_sr["B"])
end
end
end
end
Pino
July 2, 2023, 4:43pm
5
thanks, trying this solution now. A bit strange that I haven’t found a reliable way to programmaticaly import and read a bunch of excel files for analysis in Julia.
Meanwhile it is clear, why readxlsx()
is not suitable for my XLSX
-file:
# ERROR: Styles not found for this workbook. #233
Just submitted a related PR for XLSX.jl
You may be interested in trying that out and feedback here.
opened 08:36AM - 14 May 21 UTC
```
using XLSX: readtable, readxlsx
file_path = "folder1\\folder2\\girder_re… sults_10.xlsx"
xt = readtable(file_path, "XLSX-Export")
xf = readxlsx(file_path)
```
`readtable` and `readxlsx` both return an error: `ERROR: ArgumentError: no node name`
Here is the error trace for `readxlsx`:
```
Stacktrace:
[1] nodename(::EzXML.StreamReader) at C:\Users\arpada\.julia\packages\EzXML\ZNwhK\src\streamreader.jl:255
[2] iterate(::XLSX.SheetRowStreamIterator, ::Nothing) at C:\Users\arpada\.julia\packages\XLSX\cRAtd\src\stream.jl:91
[3] iterate(::XLSX.WorksheetCache{XLSX.SheetRowStreamIterator}, ::Int64) at C:\Users\arpada\.julia\packages\XLSX\cRAtd\src\stream.jl:238
[4] iterate(::XLSX.WorksheetCache{XLSX.SheetRowStreamIterator}) at C:\Users\arpada\.julia\packages\XLSX\cRAtd\src\stream.jl:216
[5] open_or_read_xlsx(::String, ::Bool, ::Bool, ::Bool) at C:\Users\arpada\.julia\packages\XLSX\cRAtd\src\read.jl:229
[6] readxlsx(::String) at C:\Users\arpada\.julia\packages\XLSX\cRAtd\src\read.jl:37
[7] top-level scope at REPL[24]:1
```
XLSX.jl 0.7.6
Julia 1.5.3
Windows 10
[girder_results_10.xlsx](https://github.com/felipenoris/XLSX.jl/files/6477584/girder_results_10.xlsx)
1 Like
Meanwhile the PR is accepted and version XLSX v0.10.3 with the fix included is released.
1 Like
ellocco
September 12, 2024, 9:30am
9
Great work!!! - Thanks a lot!