-
Notifications
You must be signed in to change notification settings - Fork 2
/
job_dec_loading.py
30 lines (23 loc) · 983 Bytes
/
job_dec_loading.py
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
30
import pandas as pd
from datasets import load_dataset
def save_job_descriptions_to_csv(output_file, num_descriptions):
try:
# Load the job descriptions dataset from Hugging Face
dataset = load_dataset("jacob-hugging-face/job-descriptions")
# Extract the specified number of job descriptions
job_data = dataset["train"][:num_descriptions]
# Create a DataFrame
df = pd.DataFrame({
"Company Name": job_data["company_name"],
"Job Description": job_data["job_description"],
"Position Title": job_data["position_title"]
})
# Save the DataFrame to a CSV file
df.to_csv(output_file, index=False)
print(f"{num_descriptions} job descriptions saved to {output_file}")
except Exception as e:
print("Error:", str(e))
def main():
save_job_descriptions_to_csv(output_file="job_descriptions.csv", num_descriptions=50)
if __name__ == '__main__':
main()