Parsing unstructured data

I’m trying to parse a long number, (let’s say 5,000 digits long), into 12 digit sections by inserting a comma after every 12th digit, for example:

105733845843,282176398323,104494700459, 245021823106,004347245176,…

I’ve added my payment info, however this keeps giving errors about how my prompt input is too large. Is there a way to get this done?

If your goal is simply to insert a comma every 12 digits, you can use this:

def insert_every_n_chars(string: str, char: str, n: int) -> str:
    '''
    This function will take a string and insert a given character after every N characters.
    '''
    return char.join(string[i:i+n] for i in range(0, len(string), n))
2 Likes

Just copy and paste? My coding skills are limited to html I’m afraid. Thank you very much for your help. Do you know I can parse, say a number that is a million digits long?

I don’t know what your setup is, but if you have a code editor and Python installed, you would copy-paste and run the above code

Dent Thanks! Where in the code do I input my unstructured data? Do I tell this code to run against a file that contains my data? In text format? I apologize for my newbie questions, but I’ve been doing this by hand and I’m going cross-eyed