In Julia, here are tow questions:
how to fid files list in folder
D:\\working
? the files include"result_1.csv","result_2.csv","result_3.csv","result_4.csv"
after using
CSV.File
to combine CSV file, the class isvector
. how to union them into a big DataFrame?
using CSV
using DataFrames
pwd()
cd("D:\\working\\logistics\\logistics_bill\\V5")
total = CSV.File.(["result_1月.csv","result_2月.csv"]).|>DataFrame
CodePudding user response:
- To get the list of files in a directory use the
readdir
function. Then you can filter this list to keep only the files that match your needs. Alternatively you can use Glob.jl - To combine data frames use
reduce
usingvcat
the data frames:
reduce(vcat, CSV.read.(["result_1月.csv","result_2月.csv"]))
(you might want to pass some keyword arguments if you want more fancy merging, like making a union of columns incase the CSV files do not have the same schema)