Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:02:18+00:00 2026-06-04T03:02:18+00:00

I have some data that needs to be cleaned before inserting in to a

  • 0

I have some data that needs to be cleaned before inserting in to a DB. Each row represents a publication and some of them have different formatting. The only similarity is that each record is on the same row. Eg.

5: Aghasadeghi MR, Salmani AS, Sadat SM, Javadi F, Memarnejadian A, Vahabpour R, Zabihollahi R, Moshiri A, Siadat SD. Application of outer membrane vesicle ofNeisseria meningitidis serogroup B as a new adjuvant to induce stronglyTh1-oriented responses against HIV-1. Curr HIV Res. 2011 Dec 1;9(8):630-5. PubMedPMID: 22211657.
6: Ramezani A; Banifazl M; Mohraz M; Rasoolinejad M; Aghakhani A; Occulthepatitis B virus infection: A major concern in HIV-infected patients: Occult HBVin HIV. Hepat Mon. 2011 Jan 1;11(1):7-10. PubMed PMID: 22087108; PubMed CentralPMCID: PMC3206662.
7: Roohvand, F., Kossari, N. Advances in hepatitis C virus vaccines, Part one:Advances in basic knowledge for hepatitis C virus vaccine design. Expert OpinTher Pat. 2011 Dec;21(12):1811-30. Epub 2011 Oct 25. Review. PubMed PMID:22022980.
8: Chinikar, S., Javadi, A., Ataei, B., Shakeri, H., Moradi, M., Mostafavi, E., Ghiasi, S.M.Detection of West Nile virus genome and specific antibodies in Iranianencephalitis patients. Epidemiol Infect. 2011 Oct 19:1-5. [Epub ahead of print]PubMed PMID: 22008154.

You can see that some of the authors are separated by semi colon and others are separated by a comma. Rows 7 and 8 have a comma that separates the last name by the middle initial. I would like to group all of the authors and put them in an author field OR maybe even place them in their own columns. What would be the best way to separate each other these authors to do this? This is not a easy task 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:02:19+00:00Added an answer on June 4, 2026 at 3:02 am

    This can get tricky when the format is not consistent, because you need to make some assumptions. The assumption I’m making for this solution is that people won’t have names longer than 20 characters, and the titles will be at least 20 characters and not contain commas, semi-colons, or periods.

    Here is a version that will insert a tab after the final author:

    result = ''
    for line in text.split('\n'):
        result += re.sub(r'([^,;.]{20,}.*)', r'\t\1', line) + '\n'
    

    And here is a way to get a list of authors for each book:

    authors = []
    for line in text.split('\n'):
        names = re.split(r'\d+: |[^,;.]{20,}', line)[1]
        authors.append(re.findall(r'\w+,? [\w.]+', names))
    

    Result:

    >>> pprint.pprint(authors, width=200)
    [['Aghasadeghi MR', 'Salmani AS', 'Sadat SM', 'Javadi F', 'Memarnejadian A', 'Vahabpour R', 'Zabihollahi R', 'Moshiri A', 'Siadat SD.'],
     ['Ramezani A', 'Banifazl M', 'Mohraz M', 'Rasoolinejad M', 'Aghakhani A'],
     ['Roohvand, F.', 'Kossari, N.'],
     ['Chinikar, S.', 'Javadi, A.', 'Ataei, B.', 'Shakeri, H.', 'Moradi, M.', 'Mostafavi, E.', 'Ghiasi, S.M.']]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data analysis that needs to perform. On average, it would involve
I have a Microsoft SQL server DB that imports some data which needs a
I have a MySQL/Rails app that needs search. Here's some info about the data:
I have some data that I would like to visualize. Each byte of the
I have some formatted data that needs to be saved from the web page
I have some data files that I need to install together with my application
I have some data in a database that I need represented in an XML
I have some (small amount) of data that I'll need quick access to on
I have some data that won't printf.... echo works, but not printf There is
I have some data that I am displaying in 3 column format, of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.