cell_type
stringclasses 1
value | execution_count
null | outputs
sequencelengths 0
0
| source
stringclasses 4
values | category
stringclasses 1
value | cell_name
stringclasses 4
values | description
stringclasses 4
values | placeholders
stringclasses 3
values | tags
stringclasses 1
value | trigger
stringclasses 4
values |
---|---|---|---|---|---|---|---|---|---|
code | null | [] | # COPY FILE TASK
import os
import shutil
def copy_file(src_file_path, dest_file_path):
try:
# Check if the source file exists
if not os.path.isfile(src_file_path):
raise FileNotFoundError(
f"The file {src_file_path} does not exist.")
# Copy the file
shutil.copy(src_file_path, dest_file_path)
print(f"File has been copied to {dest_file_path}")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
# Replace with the actual file path and destination file path
source_file = 'path/to/your/source/file.txt'
destination_file = 'path/to/your/destination/file_copy.txt'
copy_file(source_file, destination_file) | system | CELL_3 | this task is used to copy a file. | source_file, destination_dir | system | trigger_copy_file |
code | null | [] | # RENAME FILE TASK
import os
def rename_file(old_file_path, new_file_path):
try:
# Check if the file exists
if not os.path.isfile(old_file_path):
raise FileNotFoundError(
f"The file {old_file_path} does not exist.")
# Rename the file
os.rename(old_file_path, new_file_path)
print(f"File has been renamed to {new_file_path}")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
# Replace with the actual file paths
old_file = test_file_input
new_file = test_file_output
rename_file(old_file, new_file) | system | CELL_1 | this task is used to rename a file. | old_file, new_file | system | trigger_rename_file |
code | null | [] | # MOVE FILE TASK
import os
import shutil
def move_file(src_file_path, dest_dir_path):
try:
# Check if the source file exists
if not os.path.isfile(src_file_path):
raise FileNotFoundError(
f"The file {src_file_path} does not exist.")
# Check if destination directory exists
if not os.path.isdir(dest_dir_path):
raise NotADirectoryError(
f"The destination directory {dest_dir_path} does not exist.")
# Move the file
shutil.move(src_file_path, os.path.join(
dest_dir_path, os.path.basename(src_file_path)))
print(f"File has been moved to {dest_dir_path}")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
# Replace with the actual file path and destination directory path
source_file = test_file_input
destination_dir = test_folder_output
move_file(source_file, destination_dir) | system | CELL_2 | this task is used to move a file. | source_file, destination_dir | system | trigger_move_file |
code | null | [] | # DELETE FILE TASK
import os
def delete_file(file_path):
try:
# Check if the file exists
if not os.path.isfile(file_path):
raise FileNotFoundError(f"The file {file_path} does not exist.")
# Delete the file
os.remove(file_path)
print(f"File {file_path} has been deleted.")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
# Replace with the actual file path to delete
file_to_delete = 'path/to/your/file_to_delete.txt'
delete_file(file_to_delete) | system | CELL_4 | this task is used to delete a file. | file_to_delete, file_to_delete | system | trigger_delete_file |
No dataset card yet
- Downloads last month
- 42