Skip to content
Advertisement

Tag: string

Edit CSV file with Python

I have a CSV that looks like this String1 and string2 does NOT contain the characters ” or , variablelengthstring1 and variablelengthstring2 does NOT contain the characters ” or , The output file should look like this So I want to remove the last 6 chars on each line, i.e. “,”No” Then, I want to remove all ” from the

How can I replace a string value with its corresponding Boolean value in a nested dictionary in Python?

I was recently given a project to do for my Python college course. Basically, you save a dictionary in a csv file with csv.DictWriter, and then you load it back into another dictionary with csv.DictReader. However, for some reason, one of the automated unittests fails my function because the final dictionary contains values “True” or “False” instead of Bool values

Change date format of these string using Python

I have a string from a pdf that I want to transform it to the date format that I want to work with later, the string is 05Dec22 how can I change it to 12/05/2022? This is what i tried so far Answer If you execute the code you’ll get the following error, this is because your time string is

Remove part of a string from pd.to_datetime() unconverted values

I tried to convert a column of dates to datetime using pd.to_datetime(df, format=’%Y-%m-%d_%H-%M-%S’) but I received the error ValueError: unconverted data remains: .1 I ran: to identify the problem. 119/1037808 dates in the date column have an extra “.1” at the end of them. Other than the “.1”, the dates are fine. How can I remove the “.1” from the

how to define selection condition in regex in python

I am having a string in which some binary numbers are mentioned. I want to count number of occurrence of given pattern, but I want set my pattern above 7 digits of character, so the result should show only more than 7 characters. it means how I can set my pattern selection, so it should count only 7 digits and

Python – Use multiple str.startswith() in a for loop get their specific values

The below function parses multiple csv files in a directory and takes out values using str.startwith(). It works find using ‘firstline.startswith(‘TrakPro’)’ and ‘txt.startswith(‘Serial’)’. However, when I add a third str.startwith() i.e. txt2.startswith(‘Test’), nothing prints out, no error, appears to ignore it. What do I need to change? Basically I want to add multiple str.startwith() in the for loop pulling out

How to concatenate strings in python?

I am doing automation in python for jira with the addition of jql search inside the service As a result: two JQL queries, one to search for “closed tickets” and the second to search for “created tickets” But as a result, I can’t add rows now. Expected Result: I got two lists inside with tuples. enter image description here enter

Advertisement