Skip to content

Commit

Permalink
Format files using DocumentFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff authored Jul 15, 2023
1 parent c6fe6f9 commit 8dc8d17
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Documenter, ExcelFiles

makedocs(modules=[ExcelFiles],
sitename="ExcelFiles.jl",
analytics="UA-132838790-1",
pages=[
sitename="ExcelFiles.jl",
analytics="UA-132838790-1",
pages=[
"Introduction" => "index.md"
])

Expand Down
6 changes: 3 additions & 3 deletions src/ExcelFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function _readxl(file::ExcelReaders.ExcelFile, sheetname::AbstractString, startr

# This somewhat complicated conditional makes sure that column names
# that are integer numbers end up without an extra ".0" as their name
colnames = [isa(i, AbstractFloat) ? ( modf(i)[1] == 0.0 ? Symbol(Int(i)) : Symbol(string(i)) ) : Symbol(i) for i in vec(headervec)]
colnames = [isa(i, AbstractFloat) ? (modf(i)[1] == 0.0 ? Symbol(Int(i)) : Symbol(string(i))) : Symbol(i) for i in vec(headervec)]
else
colnames = gennames(ncol)
end
Expand All @@ -74,9 +74,9 @@ function _readxl(file::ExcelReaders.ExcelFile, sheetname::AbstractString, startr

for i = 1:ncol
if header
vals = data[2:end,i]
vals = data[2:end, i]
else
vals = data[:,i]
vals = data[:, i]
end

# Check whether all non-NA values in this column
Expand Down
14 changes: 7 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using Test
end

df, names = create_columns_from_iterabletable(load(filename, "Sheet1!C4:O7", header=false))
@test names == [:x1,:x2,:x3,:x4,:x5,:x6,:x7,:x8,:x9,:x10,:x11,:x12,:x13]
@test names == [:x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13]
@test length(df[1]) == 4
@test length(df) == 13
@test df[1] == [1., 1.5, 2., 2.5]
Expand Down Expand Up @@ -100,15 +100,15 @@ using Test
@test DataValues.isna(df[12][4])
@test df[13] == [NA, 3.4, "HKEJW", NA]

# Test for saving DataFrame to XLSX
input = (Day = ["Nov. 27","Nov. 28","Nov. 29"], Highest = [78,79,75]) |> DataFrame
# Test for saving DataFrame to XLSX
input = (Day=["Nov. 27", "Nov. 28", "Nov. 29"], Highest=[78, 79, 75]) |> DataFrame
file = save("file.xlsx", input)
output = load("file.xlsx", "Sheet1") |> DataFrame
@test input == output
rm("file.xlsx")

# Test for saving DataFrame to XLSX with sheetname keyword
input = (Day = ["Nov. 27","Nov. 28","Nov. 29"], Highest = [78,79,75]) |> DataFrame
# Test for saving DataFrame to XLSX with sheetname keyword
input = (Day=["Nov. 27", "Nov. 28", "Nov. 29"], Highest=[78, 79, 75]) |> DataFrame
file = save("file.xlsx", input, sheetname="SheetName")
output = load("file.xlsx", "SheetName") |> DataFrame
@test input == output
Expand Down Expand Up @@ -138,10 +138,10 @@ using Test
@test DataValues.isna(df[12][4])
@test df[13] == [NA, 3.4, "HKEJW", NA]

# Too few colnames
# Too few colnames
@test_throws ErrorException create_columns_from_iterabletable(load(filename, "Sheet1!C4:O7", header=true, colnames=[:c1, :c2, :c3, :c4]))

# Test for constructing DataFrame with empty header cell
# Test for constructing DataFrame with empty header cell
data, names = create_columns_from_iterabletable(load(filename, "Sheet2!C5:E7"))
@test names == [:Col1, :x1, :Col3]

Expand Down

0 comments on commit 8dc8d17

Please sign in to comment.