Sign inSign up

schogini/replace-strings-image

By schogini

Updated almost 2 years ago

Python script that replaces strings in a file based on mappings from another file

Image
0

397

schogini/replace-strings-image repository overview

Schogini Replace Strings Docker Image

This Docker image allows you to run a Python script that replaces strings in a file based on mappings from another file. It uses replace_strings.py, which reads a company.txt file containing string mappings and replaces occurrences of those strings in a voiceflow.vf file.

How It Works

The script reads the company.txt file, which contains the strings that need to be replaced and their corresponding replacements. It then processes the voiceflow.vf file and replaces all occurrences of the specified strings. The output is saved in a new file named out-company-voiceflow.vf.

Example company.txt Structure:
STRING TO BE REPLACED1||STRING TO BE USED TO REPLACE1
STRING TO BE REPLACED2||STRING TO BE USED TO REPLACE2
Example replace_strings.py Workflow:

For instance, if company.txt contains:

old_value1||new_value1
old_value2||new_value2

And voiceflow.vf contains:

This is old_value1 and here is old_value2.

The script will replace old_value1 with new_value1 and old_value2 with new_value2, resulting in the following output in out-company-voiceflow.vf:

This is new_value1 and here is new_value2.

Usage

Prerequisites
  • Docker must be installed on your machine.
Build the Docker Image

To build the Docker image, run the following command:

docker build -t schogini/replace-strings-image .
Run the Docker Container

To run the container and execute the script:

docker run --rm -v $(pwd):/app schogini/replace-strings-image company.txt voiceflow.vf
Parameters
  • company.txt: The file containing the strings to be replaced and their replacements (formatted as old_value||new_value).
  • voiceflow.vf: The file in which the replacements will be made.
Example Command
docker run --rm -v $(pwd):/app schogini/replace-strings-image company.txt voiceflow.vf
Help Command

To display help on how to use the script:

docker run --rm -v $(pwd):/app schogini/replace-strings-image --help

Output

The output file will be saved as:

out-company-voiceflow.vf

Files in the Docker Image

  • replace_strings.py: The Python script that handles the string replacement.
  • Dockerfile: The Dockerfile that builds the image using the Python 3.9 slim base image.

Company Information

This Docker image was created by Schogini Systems Private Limited. We specialize in AI Chatbot and Automation solutions for small businesses.

For more information about our services, visit: https://www.schogini.com.

License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:778ca6bd3

Size

45 MB

Last updated

almost 2 years ago

docker pull schogini/replace-strings-image