SatishFaction commited on
Commit
cef39e3
·
verified ·
1 Parent(s): 692a498

data_download script

Browse files
Hin_ST_PR.csv ADDED
The diff for this file is too large to render. See raw diff
 
Letters_Hindi.csv ADDED
The diff for this file is too large to render. See raw diff
 
MR_Letters.csv ADDED
The diff for this file is too large to render. See raw diff
 
MR_ST_Para.csv ADDED
The diff for this file is too large to render. See raw diff
 
MR_Words.csv ADDED
The diff for this file is too large to render. See raw diff
 
Words_Hindi.csv ADDED
The diff for this file is too large to render. See raw diff
 
data_download_script.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pandas as pd
3
+ import requests
4
+ df=pd.read_csv("MR_Words.csv")
5
+
6
+ def download_audio_from_dataframe(df, url_column, folder_path):
7
+ for index, row in df.iterrows():
8
+ audio_url = row[url_column]
9
+ if pd.notna(audio_url) and isinstance(audio_url, str):
10
+ file_name = os.path.basename(audio_url)
11
+
12
+ try:
13
+ # Create the folder if it doesn't exist
14
+ os.makedirs(folder_path, exist_ok=True)
15
+
16
+ # Combine folder path and file name to get the full path
17
+ full_path = os.path.join(folder_path, file_name)
18
+
19
+ # Send a GET request to the URL
20
+ response = requests.get(audio_url)
21
+
22
+ # Check if the request was successful (status code 200)
23
+ if response.status_code == 200:
24
+ # Open a local file and write the content of the response
25
+ with open(full_path, 'wb') as audio_file:
26
+ audio_file.write(response.content)
27
+ print(f"Audio file downloaded successfully to {full_path}")
28
+ else:
29
+ print(f"Failed to download audio file. Status code: {response.status_code}")
30
+
31
+ except Exception as e:
32
+ print(f"Error: {e}")
33
+ print(file_name)
34
+ continue
35
+
36
+ # Example usage
37
+ # Assuming you have a DataFrame named 'df' with a column 'audio_links' containing URLs with filenames
38
+
39
+
40
+ # Specify the column name
41
+ url_column_name = 'recordingserverurl'
42
+
43
+ # Specify the download folder
44
+ download_folder = 'path_to/Marathi/words'
45
+
46
+ # Call the function to download audio files
47
+ download_audio_from_dataframe(df, url_column_name, download_folder)
48
+