Read data from various csv and store it in one dataframe

0 votes
Hi, How to store data from multiple Excel sheets and store it in a single dataframe. The sheets contains the same structure i.e columns with same or different number of records. The sheets contain details of products, sales, orders, etc of different branches of a store.
Jul 2 in Data Analytics by piyush
12 views

1 answer to this question.

0 votes

Use rbind() to join both data frames into one data frame.

Read both the sheets in separate data frames.-

Then use rbind() like below- for example i used global siperstore.xlsx file

>  library(openxlsx)
> data_sheet1 = read.xlsx("C:\\Users\\Cherukuri_Sindhu\\Downloads\\global_superstore_2016.xlsx",sheet = 1)
> data_sheet2 = read.xlsx("C:\\Users\\Cherukuri_Sindhu\\Downloads\\global_superstore_2016.xlsx",sheet = 2)
> final_dataframe = rbind(data_sheet1,data_sheet2)

Make sure to have same number of columns of both sheets else below error would pop up - 

I used the same sheet with the first 6 rows and last 6 rows in different data frames to combine them in a new data frame

Hope it helps you.

answered Jul 4 by anonymous
• 17,870 points

Related Questions In Data Analytics

0 votes
0 answers

Split a string and store it in multiple columns from a field in R

How to Split a string and store ...READ MORE

Jun 28 in Data Analytics by Anand
22 views
0 votes
1 answer

How to calculate group mean and assign it to new data in R

You can use something like this: df$grp.mean.values <- ...READ MORE

answered Jun 27, 2018 in Data Analytics by darklord
• 6,140 points
40 views
0 votes
2 answers

"Train" and "Test" sets in Data Science

Normally to perform supervised learning you need ...READ MORE

answered Aug 2, 2018 in Data Analytics by ANMOL
• 3,620 points
33 views
+1 vote
1 answer

Finding number of missing values and removing those missing values from a data-frame

This code gives the total number of ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
27 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
64 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
78 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
60 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
41 views
0 votes
1 answer

Top N and Last N records in R Data Frame

Use head() to fetch first N rows ...READ MORE

answered Jul 4 in Data Analytics by anonymous
• 17,870 points
12 views
0 votes
1 answer

Difference between List(list1,list2) and c(list1,list2) in R

Hi Deepa, It's quite simple, let me explain ...READ MORE

answered Jun 26 in Data Analytics by Cherukuri
• 17,870 points
38 views