I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
To achieve this, you can modify the command to first check if the text file already exists before running the python script. Here's how you can do it:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.pdf}.txt" ]; then python3 process.py "$0" "${0%.pdf}.txt"; fi' {} \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.pdf}.txt" ]; then python3 process.py "$0" "${0%.pdf}.txt"; fi' {} \; |
Running the following program:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.pdf}.txt" ]; then python3 process.py "$0" "${0%.pdf}.txt"; fi' {} \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Sure, you can modify your command to check if the output file already exists before running the Python script. Here's an example of how you can do this using a bash script:
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash for pdf in $(find . -name "*.pdf"); do txt_file="${pdf%.pdf}.txt" # Replace .pdf with .txt txt_file="txt/${txt_file}" # Add the txt/ prefix if [ ! -f "$txt_file" ]; then # If the file does not exist python3 process.py "$pdf" "$txt_file" # Run your script fi done |
I extracted the following code from that output:
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash for pdf in $(find . -name "*.pdf"); do txt_file="${pdf%.pdf}.txt" # Replace .pdf with .txt txt_file="txt/${txt_file}" # Add the txt/ prefix if [ ! -f "$txt_file" ]; then # If the file does not exist python3 process.py "$pdf" "$txt_file" # Run your script fi done |
Running the following program:
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash for pdf in $(find . -name "*.pdf"); do txt_file="${pdf%.pdf}.txt" # Replace .pdf with .txt txt_file="txt/${txt_file}" # Add the txt/ prefix if [ ! -f "$txt_file" ]; then # If the file does not exist python3 process.py "$pdf" "$txt_file" # Run your script fi done |
final: True Resulting in output: True
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Sure, you can modify your command to check if the text file already exists before running the python script. Here's how you can do it:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.*}.txt" ]; then python3 process.py "$0" "${0%.*}.txt"; fi' {} \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.*}.txt" ]; then python3 process.py "$0" "${0%.*}.txt"; fi' {} \; |
Running the following program:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "${0%.*}.txt" ]; then python3 process.py "$0" "${0%.*}.txt"; fi' {} \; |
Traceback (most recent call last): File "/usr/src/app/check.py", line 6, in <module> print('final: ' + str(check_ok())) File "/usr/src/app/check.py", line 3, in check_ok return open("txt/a.txt").read() == "done1" and open("txt/b.txt").read() == "hello2" and open("txt/c.txt").read() == "done3" and len(os.listdir("txt")) == 3 FileNotFoundError: [Errno 2] No such file or directory: 'txt/b.txt' Resulting in output: False
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Sure, I can help you modify the command to meet your requirements. To avoid rewriting files that already exist, you can use a simple check in your command. Here's how you can do it:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
Running the following program:
1 | find . -name "*.pdf" -exec sh -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
final: True Resulting in output: True
I have setup the docker container to run the model evaluation.
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Run find . -name "*.pdf" -exec python3 process.py {} txt/{}.txt \; but don't rewrite files that already exist. Instead of .pdf.txt make it just .txt
Sure, you can modify your command to check if the text file already exists before running the python script. Here's how you can do it:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
I extracted the following code from that output:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
Running the following program:
1 | find . -name "*.pdf" -exec bash -c 'if [ ! -f "txt/${1%.pdf}.txt" ]; then python3 process.py "$1" "txt/${1%.pdf}.txt"; fi' _ {} \; |
final: True Resulting in output: True