initial scripts
This commit is contained in:
parent
6b14aa4acd
commit
77e9c9186a
5 changed files with 320 additions and 0 deletions
45
foundryVTTRolltablepdf2json/coulumnsplit.sh
Executable file
45
foundryVTTRolltablepdf2json/coulumnsplit.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Input and output files
|
||||
input_file="columnized.txt"
|
||||
output_file="decolumnized.txt"
|
||||
|
||||
# Process the input file
|
||||
awk '
|
||||
# Function to print the table header
|
||||
function print_table_header(table) {
|
||||
if (table != "") {
|
||||
print ""
|
||||
print "### " table
|
||||
table = ""
|
||||
}
|
||||
}
|
||||
|
||||
/^ *TABLE [0-9]+/ { # Detect table headers
|
||||
table = $0
|
||||
next
|
||||
}
|
||||
|
||||
/^[0-9]+–[0-9]+/ || /^[0-9]+/ { # Match rows starting with "1–6", "7–9", etc.
|
||||
left = substr($0, 1, 50) # Extract left column (first 50 chars)
|
||||
right = substr($0, 51) # Extract right column (remaining chars)
|
||||
|
||||
# Trim whitespace from both sides of each column
|
||||
gsub(/ +$/, "", left)
|
||||
gsub(/^ +/, "", left)
|
||||
gsub(/ +$/, "", right)
|
||||
gsub(/^ +/, "", right)
|
||||
|
||||
# Print the table header if a new row is starting
|
||||
print_table_header(table)
|
||||
|
||||
# Print left column (if it exists) as part of the output
|
||||
if (left != "") {
|
||||
print "- **" left "**: " right
|
||||
} else if (right != "") {
|
||||
print right
|
||||
}
|
||||
}' "$input_file" > "$output_file"
|
||||
|
||||
echo "Reformatted content saved to $output_file"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue