writing small dataframe to csv creates a huge file

375 Views Asked by At

I am trying to write the dataframe T_df into a csv file, however the saved "TFile.csv" file grows to approx 50GB on the Microsoft Azure / R server. Has someone experienced something similar and can please advise?

Example:

write.csv(T_df,"TFile.csv")

creates 50GB file, while dataframe is not that big

object.size(T_df)
2449776 bytes

str(T_df)
'data.frame':   101994 obs. of  3 variables:
1

There are 1 best solutions below

0
On

Don't know if there's something special about your particular data but I don't see this when I run Microsoft R Server version 9.3.0.

> T_df <- data.frame(a = runif(101994), b = runif(101994), c = runif(101994))
> object.size(T_df)
2448752 bytes
> str(T_df)
'data.frame':   101994 obs. of  3 variables:
 $ a: num  0.248 0.504 0.197 0.634 0.407 ...
 $ b: num  0.226 0.686 0.556 0.629 0.412 ...
 $ c: num  0.959 0.122 0.214 0.666 0.23 ...
 > 
 > write.csv(T_df,"TFile.csv")

TFile.csv is 6.1 M