codingdir logo sitemap sitemap |

Ignore bracket in csv file python

By : , Category : python

The relevant code is the part where you buld a regular expression using a user input, without sanitizing it. You should not do that.

I believe you don't need to use RE at all. you can find matching string using if item in path or path.endswith(item) or something like that.

The best option is to use your library:

from os.path import basename
orderedpaths = [ ... if basename(path) == item]

If you insist on using REs, you should escape your input using re.escape():

orderedpaths = [path for item in target for path in filenames
                 if, path)]
ReLated :

You made a string out of {d:e} by putting quotes around the whole thing. Change '{d:e}' to {'d':'e'}.

In [57]: data = {'A':{'B':{ 'c':{'d':'e'}}}}

In [58]: print yaml.dump(data)
    c: {d: e}

matchRecursive found at

Try this:

usedbeforefile = open(r'c:Documents and SettingsAdamDesktopNewProgramResourcesAlfredub4.txt')

Notice the r before the start of the string. That's the way to say: this is a raw string, there's no need to interpret as a special escape character. Another alternative would be to use normal strings and manually escape all characters:

usedbeforefile = open('c:\Documents and Settings\Adam\Desktop\NewProgram\Resources\Alfred\ub4.txt')

do this:

measurement = [float(split[i]) for i in [6]]
ofile.write(str(name) + "," + str(wavelength) + "," + ",".join(measurement) + '


ofile.write(str(name) + "," + str(wavelength) + "," + split[6] + '

Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © All Rights Reserved .