How to Script

sup Sup Forums

I have a number of text files I need to make into a different text files. I want to write a script that will; open it, cut out the parts I need, and create a new file with the parts in a different format. The pieces i need are clearly labeled but vary in quantity and length.

This doesn't seem like a difficult thing to do but I have very limited coding experience. What's a good resource to get into scripting? Is there a tutorial out there that deals specifically with altering text files? I hear Python is a thing. If I wanted a simple GUI is VB.NET the way to go?

Help please.

Other urls found in this thread:

technet.microsoft.com/en-us/library/ee176977.aspx
twitter.com/NSFWRedditGif

Install Gentoo

I'd help you but you didn't post in the small/stupid questions thread. also just google "editing text files with python"

Or, ya know, you could help me anyways.

I've looked at python before for other things but never found a good tutorial to get what I need done quickly. Unfortunately I don't really have the time I would like to learn something complex.

Found a decent tutorial for VBScript and .hta GUI. Think ill start with that.

Definitely VBScript, it's the hottest thing right now.

I don't really care if its cutting edge. I just need to automate shit easily and quickly in Windows.

>Or, ya know, you could help me anyways.
Hmm, help someone who's breaking the rules (/r/ thread outside of /r/, /wsr/) and wasting a thread on spoofeeding them (theres a limit to how mnay threads can be on Sup Forums at one time you know)
>I don't really have the time I would like to learn something complex.
it's not complex and you don't have 1 hour spare a week? how much time a day do you spend watching TV, because that's spare time
>good tutorial to get what I need done quickly.
I've never done python before, I googled "editing text files in python" and in under 5 minutes I've made a working script that searched through a text file and removed all punctuation, made everything lowercase, removed words with an odd number of letters and swapped the letter a for b

You're just lazy and want someone to do it for you, I mean you haven't even posted what you want doing to the text files so how are people meant to help you?

so you described the problem and suggested using python and why don't you do it? if you want to get into scripting languages it's the best bet because of popularity.
want a gui in windows, use one of the gui frameworks that has python bindings like qt.
if you really want something that has build in gui development on windows it's probably better to just fall for the c# meme, not a scripting language but not as as vb.

>theres a limit to how mnay threads can be on Sup Forums at one time you know
You're right. I should've known better. I don't spend a huge amount around time here anymore and forgot about simple question threads.

>it's not complex
>removed all punctuation, made everything lowercase, removed words with an odd number of letters and swapped the letter a for b
That's pretty complex for someone who doesn't do this on a regular basis. It's likely I can do a lot of things that I find trivial that you would be impressed by too.

>how much time a day do you spend watching TV
Not a lot but I know that's not the point you were trying to make. I have other hobbies I could sacrifice to learn to code if I really wanted to. What I am trying to do is for work so I don't want to waste a tonne of personal time but also can't afford to spend hours trying to get a simple script working at work.

>You're just lazy and want someone to do it for you
Not the case. I specifically did not give enough information so people would not assume this. I wan't to learn to do a very specific thing. I am asking for the best approach.

I mentioned python because from my little understanding of this kind of stuff it seemed like a good solution. I watched a youtube video about parsing text with python. It made it look almost too easy. I don't fully understand how it works so I assume there must be something I'm missing and will therefore get very frustrated trying to learn it on my own with no computer science background.

Where as with VBScript I found a nice tutorial about opening, editing, and closing text files so I can understand how the specific components I am needing work. I was hoping there was something similar but for a more relevant language.

>I found a nice tutorial about opening, editing, and closing text files

If anyone is curious about the level I am talking about, I am currently going through "Sesame Script":

technet.microsoft.com/en-us/library/ee176977.aspx

>tutorial about vbscript
yeah I rather kill myself

What makes it so bad?

it's a fucking meme language, use python it's easy and works on every os, what're you trying to do to the text I'll tell you what to search

I can't remember exactly off the top of my head what the data looks like but I can give you a rough idea. buried down in a text file there is something like:

(Number1)
A12_B24_C36
(Number2)
D12_E24_F130

I need to make that into:

$Number-1$
A-12, B-24, C-36
$Number-2$
D-12, E24, F130

All the info is basically the same. It just needs to be presented in a different way.

If you give me all of the details on what you need I'll write it for you in ruby

bruh u can learn python file editing in an 2 hours. Just fkin google it you retard. Also fuck actually reading contents. From your format, you know every 2 lines you have data. So Every 2 lines you rewrite data

>open it, cut out the parts I need, and create a new file with the parts in a different format
GOOGLE IT
O
O
G
L
E

I
T

I appreciate the offer but it would kind of defeat the purpose of me learning how to do this.

The issue has never been knowing what to do. I can do it manually and therefore can instruct someone or a computer how do it. The issue was always knowing how to input the instructions into a language a computer can understand.

use sed

if you are going to just work with text look into awk/sed

1. Pick one of the following langauges: C#, Python, Ruby, Perl, Lua, VBA.

2. Google your task in step, i.e. "how to open a file in [your language]", then "how to find a current line in a file", "how to copy text.." and so on.

3. Generally GUIs and scritpting langauges don't have much overlap. But yes, VB.net or VBA will provide you the most simple access to GUIs if you want to.

1- Create a list
2- slice

for example

';'.join("a,b,c".split(','))

For pretty much every OS but Windows:

For one file, sed 's/[()]/$/g;s/_/, /g' infile > outfile
If you want to use it on multiple files, for f in *; do sed 's/[()]/$/g;s/_/, /g' "$f" > "$f.out"; done

Get a better os.