Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

get_data.py 864 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. #The main objective for this code is it will read params.yaml process it and return to a dataframe
  2. import os #handling file
  3. import argparse #for argument parsing
  4. import yaml #yaml file calling
  5. import pandas as pd #dataframe calling
  6. def read_params(config_path):
  7. with open(config_path) as yaml_file:
  8. config=yaml.safe_load(yaml_file)
  9. return config
  10. def get_data(config_path):
  11. config=read_params(config_path)
  12. print(config)
  13. data_path=config["data_source"]["local_data"]
  14. raw_path=config["raw_data"]["raw"]
  15. data=pd.read_csv(data_path,sep=",")
  16. raw_data=pd.read_csv(raw_path,sep=",")
  17. print(raw_data.head())
  18. return data
  19. if __name__=="__main__":
  20. args=argparse.ArgumentParser()
  21. args.add_argument("--config",default="params.yaml")
  22. parsed_args=args.parse_args()
  23. data=get_data(config_path=parsed_args.config)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...