Help with invalid literal for int() with base 10

I have encountered the following problem in Cleaning and Preparing Data in Python 8/10.

def process_date(date_list):
    `split_date = []`
    res_list = []
    for entry in date_list:
        if '-' in entry:
            split_date = entry.split('-')
            date_1 = int(split_date[0])
            date_2 = int(split_date[1])
            res = round((date_1 + date_2) / 2)
            res_list.append(res)
        else:
            res = int(entry)
            res_list.append(res)
    return res_list

The int returns β€œinvalid literal for int() with base 10”.

The code should work as it works for a smaller dataset.

Please provide the url to the mission.

Use back ticks to format the code. See the post below on how to use back ticks.

The conversion is invalid because the string to be converted does not contains numeric digits.

@alvinctk
Formatted.
But how can this be? This is what I see when print the dates.
The process_date() function should convert this data.

I have to check on the code itself. Please provide the url to the mission. Thanks.

Of source, please use this link:
https://app.dataquest.io/m/351/cleaning-and-preparing-data-in-python/8/parsing-numbers-from-complex-strings-part-two

Here is my working code:

def process_date(s):
    if "-" in s:
        x, y = map(int, s.split("-"))
        return round((x+y)/2)
    else:
        return int(s)

processed_test_data = [process_date(s) for s in stripped_test_data]
for row in moma:
    row[6] = process_date(strip_characters(row[6]))
    

For mission 351 - parsing-numbers from complex strings part two:

Your code with error:

It needs to return an integer and not a list.

About your bug/error:

The code above loop through each character of a given string.

When character entry = "-",

And perform split_date = entry.split('-').

It becomes split_date = [""].

When you try to convert

date_1 = int(split_date[0])
date_1 = int("") 

That’s when the error happens because you cannot convert an empty string into an integer.

To fix your bug/error:

def process_date(entry):

    if '-' in entry:
        split_date = entry.split('-')
        date_1 = int(split_date[0])
        date_2 = int(split_date[1])
        return round((date_1 + date_2) / 2)
            
    else:
       return int(entry)

Or my alternative solution:

Entire solution:

Hey @jiajun.j.yuan,

I have updated my above post with commentary on why your bug happens and a fix for your bug.

Let me know if you have any more queries.

We have a solved feature that allows you the ability to mark something as the β€œcorrect” answer, which helps future students with the same question quickly find the solution they’re looking for.

Here’s an article on how to mark posts as solved - I don’t want to do this for you until I know that solution/explanation works.

Best,
Alvin

@alvinctk
Thanks.
Looking at the raw data, I see there were entries like '-1914', which explains why int("") doesn’t work.

But when I tried both the solution method and your method, they also failed with '-1914'. If it cannot solve this instance, how can it solve a list?

Solution method:


Your method:

The data input into the function process_date is one of the following:

  • a single year - i.e. β€œ1999”
  • a year range - i.e. β€œ1900-1999”

In your example, the data input is not supported by the function process_date. Of course it will break.

>>> "-1914".split("-")
['', '1914']

Since the first index is an empty string.

Here is my entire code that pass the checker.

test_data = ["1912", "1929", "1913-1923",
             "(1951)", "1994", "1934",
             "c. 1915", "1995", "c. 1912",
             "(1988)", "2002", "1957-1959",
             "c. 1955.", "c. 1970's", 
             "C. 1990-1999"]

bad_chars = {"(",")","c","C",".","s","'", " "}

def strip_characters(string):
     return "".join(c for c in string if c not in bad_chars)

stripped_test_data = ['1912', '1929', '1913-1923',
                      '1951', '1994', '1934',
                      '1915', '1995', '1912',
                      '1988', '2002', '1957-1959',
                      '1955', '1970', '1990-1999']

def process_date(s):
    if "-" in s:
        x, y = map(int, s.split("-"))
        return round((x+y)/2)
    else:
        return int(s)

processed_test_data = [process_date(s) for s in stripped_test_data]
for row in moma:
    row[6] = process_date(strip_characters(row[6]))

If you download the raw data artworks.csv, you can see there are no entries of β€œ-year”. On the DQ platform, column six of artworks.csv shows a cropped value β€œ1889-” since it is longer than the column width.
On the artworks.csv, its value is β€œ1889-1911”.

@alvinctk
If you download the raw data artworks.csv, you can see there are no entries of β€œ-year”.

Python may read those values as (1940), or negative.
But please take a look at this:


11

These are values from moma's Date column:

[β€˜1986’,
β€˜1978’,
β€˜1889-1911’,
β€˜1927-1940’,
β€˜1903’,
β€˜1957’,
β€˜1924’,
β€˜1978-1983’,
β€˜2001’,
β€˜(1941)’,
β€˜1949-1950’,
β€˜1963’,
β€˜1908-1911’,
β€˜(1934)’,
β€˜1997’,
β€˜(1931-1933)’,
β€˜1972’,
β€˜1967’,
β€˜1923-1924’,
β€˜1979’,
β€˜1925-1927’,
β€˜1929’,
β€˜1972’,
β€˜1974’,
β€˜1957’,
β€˜1920-1930’,
β€˜1974’,
β€˜1915’,
β€˜1912’,
β€˜1988-1990’,
β€˜1925’,
β€˜c. 1925’,
β€˜1980’,
β€˜1964’,
β€˜1968’,
β€˜1969’,
β€˜1934’,
β€˜1953’,
β€˜1971’,
β€˜1988’,
β€˜1818’,
β€˜2002’,
β€˜1926’,
β€˜1969’,
β€˜1914’,
β€˜1979’,
β€˜1968’,
β€˜1979’,
β€˜1966’,
β€˜1904’,
β€˜1949’,
β€˜1981’,
β€˜1970’,
β€˜1969’,
β€˜1972’,
β€˜1923-1925’,
β€˜1967’,
β€˜1932’,
β€˜1928’,
β€˜1965’,
β€˜2003’,
β€˜1971-1974’,
β€˜1983’,
β€˜1930’,
β€˜1946’,
β€˜1984’,
β€˜2006’,
β€˜c. 1885’,
β€˜1942’,
β€˜1913’,
β€˜2015’,
β€˜1987’,
β€˜1947-1949’,
β€˜1965’,
β€˜1818’,
β€˜1961’,
β€˜1925’,
β€˜1916-1932’,
β€˜1962’,
β€˜1944’,
β€˜1930’,
β€˜1991’,
β€˜1991-1994’,
β€˜2008’,
β€˜1975’,
β€˜1893’,
β€˜1966’,
β€˜1968-1969’,
β€˜1964-1968’,
β€˜1928-1939’,
β€˜1969’,
β€˜1942’,
β€˜1980’,
β€˜1955’,
β€˜1930’,
β€˜c. 1955-1960’,
β€˜1922’,
β€˜c.1934’,
β€˜1903’,
β€˜2008’,
β€˜1962’,
β€˜1944’,
β€˜1914-1918’,
β€˜(2003)’,
β€˜2012’,
β€˜1965’,
β€˜1865’,
β€˜1976’,
β€˜1902’,
β€˜2003’,
β€˜2010’,
β€˜1944’,
β€˜1963’,
β€˜1875’,
β€˜1948’,
β€˜1990’,
β€˜1913’,
β€˜1958’,
β€˜1921’,
β€˜1970’,
β€˜1950’,
β€˜2004’,
β€˜1926’,
β€˜1973’,
β€˜1915’,
β€˜2003’,
β€˜1973’,
β€˜1986’,
β€˜1982’,
β€˜1908-1911’,
β€˜1934’,
β€˜1971’,
β€˜(1926)’,
β€˜1960’,
β€˜1939’,
β€˜1893’,
β€˜c.1952’,
β€˜2007’,
β€˜1933-1947’,
β€˜1995’,
β€˜1973’,
β€˜1939’,
β€˜1913’,
β€˜1908’,
β€˜1971’,
β€˜1936’,
β€˜1960’,
β€˜1975’,
β€˜1976’,
β€˜2005’,
β€˜1933’,
β€˜1957’,
β€˜1960’,
β€˜1982’,
β€˜1956’,
β€˜1910’,
β€˜1983’,
β€˜1968-1977’,
β€˜1969’,
β€˜1965’,
β€˜1919-1920’,
β€˜1923-1948’,
β€˜c.1973’,
β€˜1912-1926’,
β€˜1905’,
β€˜1918’,
β€˜1997’,
β€˜1875’,
β€˜1907’,
β€˜1926-1946’,
β€˜1999’,
β€˜1929’,
β€˜1991-1994’,
β€˜1971’,
β€˜1942’,
β€˜1933’,
β€˜1965’,
β€˜1936-1937’,
β€˜2011’,
β€˜1978-1979’,
β€˜1951’,
β€˜1926’,
β€˜2004’,
β€˜1919-1920’,
β€˜1965-1966’,
β€˜1923-1951’,
β€˜1991’,
β€˜1916-1932’,
β€˜1964’,
β€˜1969’,
β€˜2001’,
β€˜1953’,
β€˜1965’,
β€˜1913’,
β€˜1930’,
β€˜(c. 1900-1910)’,
β€˜2010’,
β€˜1992’,
β€˜1913’,
β€˜1931-1956’,
β€˜1875’,
β€˜1989’,
β€˜1962’,
β€˜2010’,
β€˜1964’,
β€˜1927’,
β€˜1997’,
β€˜1962’,
β€˜c. 1940’,
β€˜1952’,
β€˜c.1946’,
β€˜1960’,
β€˜1900’,
β€˜2013’,
β€˜1928’,
β€˜1978’,
β€˜1986’,
β€˜1899-1900’,
β€˜1920-1930’,
β€˜1932’,
β€˜1985-1986’,
β€˜1966’,
β€˜1968’,
β€˜1974’,
β€˜1998’,
β€˜2000’,
β€˜2006’,
β€˜1967’,
β€˜1965’,
β€˜1927’,
β€˜2004’,
β€˜1979’,
β€˜(1916)’,
β€˜2009’,
β€˜1978’,
β€˜1964’,
β€˜1958’,
β€˜1872-1927’,
β€˜1967’,
β€˜1988’,
β€˜1928’,
β€˜2003’,
β€˜c. 1923-1924’,
β€˜1964’,
β€˜c. 1900’,
β€˜1975’,
β€˜1978’,
β€˜1913-1921’,
β€˜1826-1896’,
β€˜1929’,
β€˜1991’,
β€˜2012’,
β€˜1926-1938’,
β€˜1982’,
β€˜1963’,
β€˜1962-1963’,
β€˜(1919)’,
β€˜1970-1971’,
β€˜1959-1965’,
β€˜2000’,
β€˜2004’,
β€˜1877’,
β€˜1914’,
β€˜1949-1950’,
β€˜1956’,
β€˜2004’,
β€˜1948’,
β€˜1921-1922’,
β€˜1965’,
β€˜1933’,
β€˜1910’,
β€˜1970’,
β€˜1947-1955’,
β€˜1881’,
β€˜1932’,
β€˜2006’,
β€˜1953-1954’,
β€˜1943-1981’,
β€˜1994’,
β€˜2006’,
β€˜(1965)’,
β€˜1942’,
β€˜1931-1956’,
β€˜1977’,
β€˜2005’,
β€˜1967’,
β€˜1971-1973’,
β€˜1981’,
β€˜1972’,
β€˜1955-1956’,
β€˜2008’,
β€˜1963’,
β€˜1926’,
β€˜1922’,
β€˜c. 1964’,
β€˜1899-1900’,
β€˜1911-1950’,
β€˜1920’,
β€˜1946-1949’,
β€˜1956’,
β€˜1982’,
β€˜1908-1911’,
β€˜1947’,
β€˜1946-1947’,
β€˜1938’,
β€˜1996’,
β€˜1998’,
β€˜1988’,
β€˜1973’,
β€˜1972’,
β€˜1970-1972’,
β€˜1925-1927’,
β€˜1971-1974’,
β€˜1921’,
β€˜1964’,
β€˜1943’,
β€˜1961’,
β€˜1935’,
β€˜1939’,
β€˜1977’,
β€˜2003’,
β€˜1961’,
β€˜2001’,
β€˜(1966)’,
β€˜1975’,
β€˜1900-1953’,
β€˜(2008-2010)’,
β€˜1988’,
β€˜1917’,
β€˜1930’,
β€˜1978’,
β€˜2007’,
β€˜1920’,
β€˜1902’,
β€˜1818’,
β€˜1925’,
β€˜1984’,
β€˜1929’,
β€˜1857’,
β€˜1943-1981’,
β€˜1973’,
β€˜1934’,
β€˜1980’,
β€˜1921’,
β€˜1995’,
β€˜1969’,
β€˜1971’,
β€˜1958’,
β€˜1931’,
β€˜1925-1927’,
β€˜1976’,
β€˜1989-1990’,
β€˜1967’,
β€˜1953’,
β€˜1961’,
β€˜1999-2001’,
β€˜1935’,
β€˜1962-1965’,
β€˜1940’,
β€˜2001’,
β€˜c. 1912’,
β€˜1933’,
β€˜1941’,
β€˜c. 1965’,
β€˜1971’,
β€˜1958’,
β€˜1994’,
β€˜1976’,
β€˜c. 1940’,
β€˜1959’,
β€˜1935’,
β€˜1993’,
β€˜1965’,
β€˜1982’,
β€˜1972’,
β€˜1985’,
β€˜1985’,
β€˜1975’,
β€˜1998’,
β€˜1933’,
β€˜1923’,
β€˜1934’,
β€˜2005’,
β€˜c. 1930-1931’,
β€˜1930’,
β€˜1979-1984’,
β€˜1928’,
β€˜c. 1938-1960’,
β€˜1973’,
β€˜c. 1930’,
β€˜1919’,
β€˜1995’,
β€˜1932’,
β€˜1939’,
β€˜c.1931’,
β€˜1923-1948’,
β€˜1971’,
β€˜1981’,
β€˜1861’,
β€˜c.1970’,
β€˜1931’,
β€˜2001’,
β€˜1998-2003’,
β€˜1961’,
β€˜1978’,
β€˜1977-1978’,
β€˜1997-2000’,
β€˜1948’,
β€˜1958’,
β€˜1999’,
β€˜1921’,
β€˜1981’,
β€˜1982’,
β€˜1966’,
β€˜(1928-1939)’,
β€˜1908-1950’,
β€˜1964’,
β€˜c. 1945’,
β€˜1990’,
β€˜2011’,
β€˜1930’,
β€˜1968’,
β€˜c. 1962’,
β€˜1953’,
β€˜2000’,
β€˜1975’,
β€˜1933’,
β€˜1926-1938’,
β€˜(1926)’,
β€˜1906-1912’,
β€˜1988’,
β€˜1972’,
β€˜(1970)’,
β€˜c. 1977’,
β€˜1980’,
β€˜1975-1976’,
β€˜1997’,
β€˜1959’,
β€˜1918’,
β€˜1900-1943’,
β€˜1958’,
β€˜c. 1951-1952’,
β€˜1960’,
β€˜1977’,
β€˜1991-1994’,
β€˜c.1937-1938’,
β€˜1818’,
β€˜c. 1976’,
β€˜1898’,
β€˜(c. 1930)’,
β€˜1969’,
β€˜2000’,
β€˜1985’,
β€˜1983’,
β€˜(c. 1918)’,
β€˜1927’,
β€˜1949-1950’,
β€˜1946’,
β€˜1970’,
β€˜1907’,
β€˜1960’,
β€˜1917’,
β€˜c. 1950’,
β€˜1912’,
β€˜1970’,
β€˜2001’,
β€˜1972’,
β€˜1912’,
β€˜1982’,
β€˜1922’,
β€˜1964’,
β€˜1985-1990’,
β€˜1949’,
β€˜c. 1938-1960’,
β€˜1962’,
β€˜1911’,
β€˜1938’,
β€˜c. 1921’,
β€˜1928’,
β€˜(c. 1914-1920)’,
β€˜1946’,
β€˜2001’,
β€˜1944’,
β€˜1963’,
β€˜1899-1900’,
β€˜1972’,
β€˜1922’,
β€˜1951’,
β€˜1928’,
β€˜c.1952’,
β€˜2013’,
β€˜1927’,
β€˜1921’,
β€˜1968’,
β€˜1899’,
β€˜1914’,
β€˜1947-1955’,
β€˜1976’,
β€˜1966’,
β€˜1964-1968’,
β€˜1970’,
β€˜1916-1923’,
β€˜(1911)’,
β€˜1913’,
β€˜1959’,
β€˜1985’,
β€˜1921’,
β€˜1975’,
β€˜1988’,
β€˜1937’,
β€˜1972’,
β€˜2003’,
β€˜1949’,
β€˜1975’,
β€˜(1952)’,
β€˜1965’,
β€˜1905’,
β€˜2010’,
β€˜1950-1953’,
β€˜1967’,
β€˜1980’,
β€˜1954’,
β€˜2002’,
β€˜1893-1896’,
β€˜1999’,
β€˜1960-1963’,
β€˜(c .1981)’,
β€˜1953’,
β€˜1994’,
β€˜2001’,
β€˜1967’,
β€˜1923-1924’,
β€˜1911’,
β€˜(c. 1918)’,
β€˜1963’,
β€˜1976’,
β€˜1967’,
β€˜1965’,
β€˜c. 1919’,
β€˜1974’,
β€˜1924’,
β€˜c. 1950-1952’,
β€˜1931’,
β€˜1965-1966’,
β€˜1990’,
β€˜1913-1921’,
β€˜1887’,
β€˜1957’,
β€˜1873’,
β€˜1928’,
β€˜1936’,
β€˜1964’,
β€˜1950’,
β€˜1923-1948’,
β€˜1930’,
β€˜1939-1945’,
β€˜1967’,
β€˜1978’,
β€˜1973’,
β€˜1995’,
β€˜1985-1990’,
β€˜1925’,
β€˜1975-1986’,
β€˜c. 1860’,
β€˜1926’,
β€˜1901’,
β€˜2013-2014’,
β€˜1900-1943’,
β€˜1977’,
β€˜1971’,
β€˜1986’,
β€˜2004’,
β€˜1948’,
β€˜1954-1958’,
β€˜1926’,
β€˜1933’,
β€˜1966’,
β€˜1975’,
β€˜1933-1947’,
β€˜1998’,
β€˜1925’,
β€˜1919-1921’,
β€˜1923-1924’,
β€˜(1960)’,
β€˜1970-1971’,
β€˜1946-1972’,
β€˜2005’,
β€˜1968’,
β€˜1949’,
β€˜(c. 1914-1920)’,
β€˜1979’,
β€˜1931’,
β€˜1928-1939’,
β€˜1971’,
β€˜1992’,
β€˜1945’,
β€˜1961’,
β€˜1911’,
β€˜1966’,
β€˜2007’,
β€˜1963’,
β€˜1941’,
β€˜1898’,
β€˜2003’,
β€˜1984-1985’,
β€˜1990’,
β€˜1951’,
β€˜1999-2001’,
β€˜1938’,
β€˜1930’,
β€˜1826-1896’,
β€˜1968’,
β€˜1971’,
β€˜1946’,
β€˜c. 1972’,
β€˜1911’,
β€˜1978’,
β€˜1910’,
β€˜1858-1860’,
β€˜1963’,
β€˜1970’,
β€˜2010’,
β€˜1939-1943’,
β€˜1951’,
β€˜1966’,
β€˜1927’,
β€˜1942’,
β€˜1938’,
β€˜2009’,
β€˜1968’,
β€˜1912’,
β€˜1901’,
β€˜2000’,
β€˜1937’,
β€˜1936’,
β€˜1921-1922’,
β€˜1926’,
β€˜1921’,
β€˜1983’,
β€˜1981’,
β€˜1962’,
β€˜1978’,
β€˜1946-1972’,
β€˜(c. 1905)’,
β€˜1968’,
β€˜1967-1968’,
β€˜1980’,
β€˜1982’,
β€˜2013’,
β€˜1991’,
β€˜1912’,
β€˜1964-1968’,
β€˜c. 1943’,
β€˜c. 1950’,
β€˜(1966)’,
β€˜1960’,
β€˜1924’,
β€˜1957’,
β€˜1981’,
β€˜1996’,
β€˜1998’,
β€˜1925’,
β€˜1958’,
β€˜1968’,
β€˜c. 1925’,
β€˜1946-1972’,
β€˜c. 1946’,
β€˜2007’,
β€˜1962-1965’,
β€˜1893-1894’,
β€˜1941’,
β€˜1958’,
β€˜1946’,
β€˜1978’,
β€˜1928-1939’,
β€˜1875’,
β€˜c. 1938’,
β€˜1994’,
β€˜c. 1899’,
β€˜1975-1976’,
β€˜1857’,
β€˜1983’,
β€˜1980’,
β€˜1908’,
β€˜(1989)’,
β€˜1966’,
β€˜1952’,
β€˜c. 1964’,
β€˜2006’,
β€˜1948’,
β€˜1904’,
β€˜1979’,
β€˜1990’,
β€˜1938’,
β€˜1900-1910’,
β€˜1983’,
β€˜1953’,
β€˜1997’,
β€˜2002’,
β€˜1959’,
β€˜1972’,
β€˜1950’,
β€˜1991’,
β€˜1974’,
β€˜1932’,
β€˜1981’,
β€˜1908’,
β€˜1997’,
β€˜1937’,
β€˜1968’,
β€˜1990’,
β€˜1843-1847’,
β€˜1985’,
β€˜1930’,
β€˜1985’,
β€˜1955’,
β€˜1948’,
β€˜1977’,
β€˜2003’,
β€˜1933’,
β€˜1968’,
β€˜1944-1945’,
β€˜1970-1972’,
β€˜1963’,
β€˜1934’,
β€˜1956’,
β€˜1949’,
β€˜1910’,
β€˜1959’,
β€˜1925-1927’,
β€˜1974’,
β€˜c. 1929’,
β€˜1968’,
β€˜1916-1932’,
β€˜2007’,
β€˜1921’,
β€˜1970’,
β€˜1919’,
β€˜1932’,
β€˜1978’,
β€˜1951’,
β€˜1909’,
β€˜2003’,
β€˜c. 1950’,
β€˜1913’,
β€˜c. 1945’,
β€˜1999’,
β€˜c. 1990’,
β€˜1997’,
β€˜1924’,
β€˜2015’,
β€˜1972’,
β€˜1907’,
β€˜1936’,
β€˜1968-1977’,
β€˜1992-2000’,
β€˜1938’,
β€˜1961’,
β€˜1951’,
β€˜1956’,
β€˜1964’,
β€˜1964’,
β€˜1931-1937’,
β€˜1964’,
β€˜c. 1900’,
β€˜2009’,
β€˜1942’,
β€˜1928’,
β€˜1943’,
β€˜2006’,
β€˜2011’,
β€˜2004’,
β€˜1939-1945’,
β€˜(1923)’,
β€˜2004’,
β€˜1962-1963’,
β€˜1899-1900’,
β€˜1998-2009’,
β€˜1959’,
β€˜1943’,
β€˜2001’,
β€˜1963’,
β€˜1977’,
β€˜1961’,
β€˜1959’,
β€˜(2004)’,
β€˜1945’,
β€˜1980’,
β€˜1932’,
β€˜1926’,
β€˜2004’,
β€˜1934’,
β€˜2013’,
β€˜1996’,
β€˜(2003)’,
β€˜1926’,
β€˜2001’,
β€˜1966’,
β€˜(2003)’,
β€˜1947’,
β€˜1934’,
β€˜1976-1977’,
β€˜1939’,
β€˜1994’,
β€˜(1993)’,
β€˜1930’,
β€˜2006’,
β€˜1916’,
β€˜2002’,
β€˜1984’,
β€˜1970’,
β€˜1965’,
β€˜1960’,
β€˜1978’,
β€˜1993’,
β€˜1938’,
β€˜1959’,
β€˜1922’,
β€˜2009’,
β€˜1981’,
β€˜1997’,
β€˜1992’,
β€˜(1987)’,
β€˜1989’,
β€˜2007’,
β€˜1962’,
β€˜1951’,
β€˜1907’,
β€˜1970’,
β€˜c. 1920’,
β€˜1943’,
β€˜1923’,
β€˜(1951)’,
β€˜1914’,
β€˜1975’,
β€˜1945’,
β€˜1954’,
β€˜1946-1948’,
β€˜1998’,
β€˜2008’,
β€˜1965’,
β€˜1913’,
β€˜c. 1962’,
β€˜1942’,
β€˜1993’,
β€˜1991’,
β€˜1984’,
β€˜1934’,
β€˜1967’,
β€˜1990’,
β€˜1932’,
β€˜1958’,
β€˜1950’,
β€˜1957’,
β€˜1915’,
β€˜1927-1943’,
β€˜(2008-2010)’,
β€˜1925’,
β€˜1989’,
β€˜1929’,
β€˜c.1980’,
β€˜1969’,
β€˜1864-1865’,
β€˜c. 1938-1960’,
β€˜1953’,
β€˜1924’,
β€˜1925’,
β€˜1927’,
β€˜2006’,
β€˜(2002)’,
β€˜1969-1971’,
β€˜2007’,
β€˜1963’,
β€˜1983-1984’,
β€˜c. 1967’,
β€˜1972’,
β€˜1983’,
β€˜2002-2003’,
β€˜1961’,
β€˜1955’,
β€˜1967-1969’,
β€˜1951’,
β€˜2004-2005’,
β€˜1927-1952’,
β€˜1946’,
β€˜1993’,
β€˜2013’,
β€˜1977’,
β€˜1995’,
β€˜1946’,
β€˜1972-1973’,
β€˜1972’,
β€˜1962-1963’,
β€˜1930’,
β€˜1984’,
β€˜2005’,
β€˜1937-1939’,
β€˜1954-1957’,
β€˜2002’,
β€˜1940’,
β€˜(1992)’,
β€˜1921’,
β€˜1984’,
β€˜1926’,
β€˜1933’,
β€˜1963’,
β€˜c. 1930’,
β€˜1968’,
β€˜1958’,
β€˜1928-1930’,
β€˜1973’,
β€˜1927-1952’,
β€˜1951’,
β€˜2002’,
β€˜1976’,
β€˜1900’,
β€˜2004-2006’,
β€˜1991-1994’,
β€˜1909’,
β€˜1967’,
β€˜1964’,
β€˜c. 1920’,
β€˜1986’,
β€˜1908’,
β€˜2001-2003’,
β€˜1979-1984’,
β€˜(2000)’,
β€˜1906-1912’,
β€˜1900-1943’,
β€˜1979’,
β€˜1996’,
β€˜1946’,
β€˜1984’,
β€˜1956’,
β€˜1963’,
β€˜1924-1926’,
β€˜1970’,
β€˜1965’,
β€˜1961’,
β€˜1950’,
β€˜1938’,
β€˜(1961)’,
β€˜1970-1996’,
β€˜1898’,
β€˜1929’,
β€˜2001-2008’,
β€˜1970s’,
β€˜1995’,
β€˜1960’,
β€˜1973’,
β€˜1973’,
β€˜c. 1919’,
β€˜1962’,
β€˜1905’,
β€˜c. 1914’,
β€˜1979’,
β€˜1970’,
β€˜(1972)’,
β€˜1997’,
β€˜1912’,
β€˜1998’,
β€˜2003’,
β€˜1973’,
β€˜1874’,
β€˜c. 1950-1952’,
β€˜1970’,
β€˜1973’,
β€˜1981’,
β€˜1959’,
β€˜1988’,
β€˜1961’,
β€˜1906-1912’,
β€˜1961’,
β€˜1893’,
β€˜1996’,
β€˜1962’,
β€˜1967’,
β€˜1968’,
β€˜1931-1937’,
β€˜1972’,
β€˜1972’,
β€˜1984’,
β€˜1992’,
β€˜1920-1930’,
β€˜1990’,
β€˜1998’]

There are no mentioned of β€œ-year”.

moma has been cleaned from artworks.csv.
The mission uses moma.

I understand. I will try again.

1 Like

Print the 11th line from artworks.csv

sed -n "11p" artworks.csv 
STILL WATER AND FISH,David Brown Milne,(Canadian),(1882),(1953),(Male),(1941),Prints & Illustrated Books

Print the 11th line, 7th column (or 6th column when counting with 0)

sed -n "11p" artworks.csv | awk -F "," '{print $7}'
(1941)

In Microsoft Excel, (1941) becomes negative because of the parenthesis ( and ).

@alvinctk
Thanks for your help. I tried to create a function that takes list as input, and list as output, without having to loop through each one. But that means I cannot change row[6] while looping through individual elements.

Pandas can probably update a whole list with another list, but that’s for another day.

1 Like