{"id":34870493,"url":"https://github.com/interstar/transedit","last_synced_at":"2026-05-24T03:31:38.398Z","repository":{"id":210254903,"uuid":"726121429","full_name":"interstar/transedit","owner":"interstar","description":"Small Python \"text editor\" which works on a pipeline of transformation you write in code.","archived":false,"fork":false,"pushed_at":"2023-12-06T17:55:44.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-12-07T17:48:49.210Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-12-01T15:22:48.000Z","updated_at":"2023-12-07T17:48:49.211Z","dependencies_parsed_at":"2023-12-06T17:40:01.389Z","dependency_job_id":null,"html_url":"https://github.com/interstar/transedit","commit_stats":null,"previous_names":["interstar/transedit"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/interstar/transedit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interstar%2Ftransedit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interstar%2Ftransedit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interstar%2Ftransedit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interstar%2Ftransedit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interstar","download_url":"https://codeload.github.com/interstar/transedit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interstar%2Ftransedit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28040279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-25T02:00:05.988Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-25T23:16:09.480Z","updated_at":"2025-12-25T23:16:10.198Z","avatar_url":"https://github.com/interstar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TransEdit\n\nSmall Python \"text editor\" which works by applying a pipeline of transformations (written as a Python function) to the text.\n\n## Why?\n\nSometimes you have a text file. You want to run a script to process it, but see the result interactively.\n\nPerhaps you want to filter it for only the lines containing certain keywords. Perhaps do a regex based text replacement on each line.\n\nThese are the things that tools like awk and sed are great for. The classic small Unix tools.\n\nBut there's a problem with the Unix pipeline. The results appear on your terminal and are lost.\n\nOr you pipe those results into a new file. But then you can't see the result until you then open that file in a separate editor.\n\nAnd if you made a mistake in your script, you have to go back and do the whole thing again.\n\nAlternatively, you can open in a normal text editor and use the search and replace tools, doing the changes step by step, manually. But if you make a mistake, or just want to try a different transformation, rewinding is laborious.\n\n\nIn other words, we often want to do bulk processing on files, interactively, and have the option of tweaking the transformation as we look over the results.\n\nSo what we want is the benefits of both a pipeline of simple transformations AND the interactivity of a text editor.\n\nThat's where transedit comes in.\n\nIt's simple. Two panels. One for the script that processes the input file. One for the result of the processing.\n\nThe processing pipeline is non-destructive. You can change and refine your processing pipeline as much as you like.\n\nWant to hand edit and save the final results when you are satisfied? Yes, you can do that too. (In fact, you should remember to save the output buffer when you are happy with the result)\n\n## Quick start.\n\nMake sure you have the dependencies. \n\n**Additional Setup for Ubuntu**\n\nOn Ubuntu, Tkinter is not included by default. Please install it using:\n\n    sudo apt-get install python3-tk \n\n\nThe application also needs BeautifulSoup\n    \n    pip install beautifulsoup4\n    \n\nThen go into the transedit directory and run transedit on a file like this:\n\n    cd transedit\n    python ./transedit.py [PATH/TO/FILE]\n    \nIf you run it without the file to work on, you will be able to load it within the GUI.\n\nWhen the program runs, you'll see two panes. \n\nOn the left is the script editor. In this you will write a Python function called `transform` which will do the transformations on your file.\n\nThe simplest script does nothing to the file. \n\n     def transform(text) : \n         return text\n     \nTo run it, just click the `Process Script` button to apply the current processing pipeline to the currently loaded file, and show the results in the output (right-hand) panel.\n\n## The Pipeline / Processing Object\n\nYou can write any Python function that can process the text file. But to simplify building a pipeline of simple filters and transformations, there's a pipeline or process object, simply called P\n\nHere's how to use it\n\n```\ndef transform(text):\n    p = P(text).grep(\"foo\").grep_v(\"bar\").replace(\"old\", \"new\")\n    return p.run()\n```\n\nP(text) creates a P object containing the text. We can then chain up as many transformations in the form of \n\n* `grep` - a filter for only those lines that match a pattern.\n* `grep_v` - a filter for only those lines that DON'T match a pattern.\n* `replace` - a string replacement applied to each line.\n\n`run()` runs the text lines through the pipeline and returns the final transformed text, which will get displayed in the right panel.\n\n### Using Regexes\n\nP also regex-based filter and replace functions.\n* `re_search(r'PATTERN')` - filter which allows through only those lines that contain text matching the regex PATTERN. \n* `re_search_fails(r'PATTERN')` - a negated version of the re_search. Ie returns only those lines that DON'T contain text matching the regex PATTERN.\n* `re_sub(r'PATTERN',r'NEWPAT')` - regex based search and replace. Uses re.sub so can do everything Python's re can do.\n\nFor example\n\n```\ndef transform(text):\n    p = P(text).re_search_fails('youtube').re_sub(r'(.+?),(.+)',r'\\2,\\1')\n    return p.run()\n```\n\nWill find all the lines that DON'T contain the word 'youtube', and will then split those lines at the first comma, and return those two items in the reversed order. (Ie. item 2, item 1)\n\nHere's a useful way to split a text file into a part that matches a pattern, followed by a part that doesn't.\n\n```\ndef transform(text) :\n    pat=\"PATTERN\"\n    p=P(text).re_search(pat).run()\n    q=P(text).re_search_fails(pat).run()\n\n    return \"\"\"%s\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n%s\"\"\"% (p,q) \n```\n\n## Beautiful Soup\n\nWe also include BeautifulSoup, so we can process HTML etc files.\n\n```\ndef transform(text) :\n  soup = BeautifulSoup(text)\n  return soup.get_text()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterstar%2Ftransedit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterstar%2Ftransedit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterstar%2Ftransedit/lists"}