Tabular Data

Warning

This is an excerpt from the work-in-progress Clojure Data Cookbook. It is under active development and subject to change in the coming months.

If the data you’re working with is already in a tabular format, it’s relatively easy to create a tablecloth dataset from it. If you have any control over the data creation and publishing parts of your project, you will have a much better time if you follow the best practices outlined in this paper about organizing data in spreadsheets.

Summary

TODO

Further details for how to make each of these commands work are provided below.

Delimited plain-text file formats

If your data is saved in a plain-text format, loading it into a tablecloth dataset is supported out of the box.

CSV & TSV

Standard tabular file formats like .csvand .tsv Just Work:

(tc/dataset "data/tabular_data/co2_over_time.csv")

data/tabular_data/co2_over_time.csv [741 3]:

Date CO2 adjusted CO2
1958-03-01 315.70 314.44
2020-03-01 414.51 412.94
2020-04-01 416.18 413.35
(tc/dataset "data/tabular_data/co2_over_time.tsv")

data/tabular_data/co2_over_time.tsv [741 3]:

Date CO2 adjusted CO2
1958-03-01 315.70 314.44
2020-03-01 414.51 412.94
2020-04-01 416.18 413.35

Non-standard delimeters

You can also specify the column separator if it is something non-standard, but note that it must be a single character. The data/tabular_data/co2_over_time.txt file looks like this:

(slurp "data/tabular_data/co2_over_time.txt")
"Date / CO2 / adjusted CO2\n1958-03-01 / 315.70 / 314.44\n1958-04-01 / 317.46 / 315.16\n1958-05-01 / 317.51 / 314.71\n1958-07-01 / 315.86 / 315.19\n1958-08-01 / 314.93 / 316.19\n1958-09-01 / 313.21 / 316.08\n1958-11-01 / 313.33 / 315.20\n1958-12-01 / 314.67 / 315.43\n1959-01-01 / 315.58 / 315.54\n1959-02-01 / 316.49 / 315.86\n1959-03-01 / 316.65 / 315.38\n1959-04-01 / 317.72 / 315.42\n1959-05-01 / 318.29 / 315.49\n1959-06-01 / 318.15 / 316.03\n1959-07-01 / 316.54 / 315.86\n1959-08-01 / 314.80 / 316.06\n1959-09-01 / 313.84 / 316.73\n1959-10-01 / 313.33 / 316.33\n1959-11-01 / 314.81 / 316.68\n1959-12-01 / 315.58 / 316.35\n1960-01-01 / 316.43 / 316.39\n1960-02-01 / 316.98 / 316.35\n1960-03-01 / 317.58 / 316.28\n1960-04-01 / 319.03 / 316.70\n1960-05-01 / 320.04 / 317.22\n1960-06-01 / 319.58 / 317.48\n1960-07-01 / 318.18 / 317.52\n1960-08-01 / 315.90 / 317.20\n1960-09-01 / 314.17 / 317.08\n1960-10-01 / 313.83 / 316.83\n1960-11-01 / 315.00 / 316.88\n1960-12-01 / 316.19 / 316.96\n1961-01-01 / 316.90 / 316.85\n1961-02-01 / 317.70 / 317.07\n1961-03-01 / 318.54 / 317.26\n1961-04-01 / 319.48 / 317.16\n1961-05-01 / 320.58 / 317.76\n1961-06-01 / 319.77 / 317.63\n1961-07-01 / 318.57 / 317.88\n1961-08-01 / 316.79 / 318.06\n1961-09-01 / 314.99 / 317.90\n1961-10-01 / 315.31 / 318.32\n1961-11-01 / 316.10 / 317.99\n1961-12-01 / 317.01 / 317.78\n1962-01-01 / 317.94 / 317.90\n1962-02-01 / 318.55 / 317.92\n1962-03-01 / 319.68 / 318.40\n1962-04-01 / 320.57 / 318.24\n1962-05-01 / 321.02 / 318.18\n1962-06-01 / 320.62 / 318.47\n1962-07-01 / 319.61 / 318.93\n1962-08-01 / 317.40 / 318.68\n1962-09-01 / 316.25 / 319.17\n1962-10-01 / 315.42 / 318.44\n1962-11-01 / 316.69 / 318.58\n1962-12-01 / 317.70 / 318.47\n1963-01-01 / 318.74 / 318.70\n1963-02-01 / 319.07 / 318.43\n1963-03-01 / 319.86 / 318.57\n1963-04-01 / 321.38 / 319.05\n1963-05-01 / 322.25 / 319.40\n1963-06-01 / 321.48 / 319.33\n1963-07-01 / 319.74 / 319.06\n1963-08-01 / 317.77 / 319.05\n1963-09-01 / 316.21 / 319.14\n1963-10-01 / 315.99 / 319.02\n1963-11-01 / 317.07 / 318.97\n1963-12-01 / 318.35 / 319.13\n1964-01-01 / 319.57 / 319.53\n1964-05-01 / 322.26 / 319.40\n1964-06-01 / 321.89 / 319.75\n1964-07-01 / 320.44 / 319.78\n1964-08-01 / 318.69 / 320.01\n1964-09-01 / 316.70 / 319.66\n1964-10-01 / 316.87 / 319.91\n1964-11-01 / 317.68 / 319.58\n1964-12-01 / 318.71 / 319.49\n1965-01-01 / 319.44 / 319.40\n1965-02-01 / 320.44 / 319.81\n1965-03-01 / 320.89 / 319.59\n1965-04-01 / 322.14 / 319.78\n1965-05-01 / 322.17 / 319.30\n1965-06-01 / 321.87 / 319.70\n1965-07-01 / 321.21 / 320.52\n1965-08-01 / 318.87 / 320.16\n1965-09-01 / 317.81 / 320.77\n1965-10-01 / 317.30 / 320.36\n1965-11-01 / 318.87 / 320.78\n1965-12-01 / 319.42 / 320.20\n1966-01-01 / 320.62 / 320.58\n1966-02-01 / 321.60 / 320.95\n1966-03-01 / 322.39 / 321.08\n1966-04-01 / 323.70 / 321.34\n1966-05-01 / 324.08 / 321.20\n1966-06-01 / 323.75 / 321.57\n1966-07-01 / 322.38 / 321.69\n1966-08-01 / 320.36 / 321.66\n1966-09-01 / 318.64 / 321.60\n1966-10-01 / 318.10 / 321.17\n1966-11-01 / 319.78 / 321.70\n1966-12-01 / 321.03 / 321.81\n1967-01-01 / 322.33 / 322.29\n1967-02-01 / 322.50 / 321.85\n1967-03-01 / 323.04 / 321.73\n1967-04-01 / 324.42 / 322.05\n1967-05-01 / 325.00 / 322.11\n1967-06-01 / 324.09 / 321.91\n1967-07-01 / 322.54 / 321.85\n1967-08-01 / 320.92 / 322.22\n1967-09-01 / 319.25 / 322.23\n1967-10-01 / 319.39 / 322.47\n1967-11-01 / 320.73 / 322.65\n1967-12-01 / 321.96 / 322.74\n1968-01-01 / 322.57 / 322.53\n1968-02-01 / 323.15 / 322.50\n1968-03-01 / 323.89 / 322.55\n1968-04-01 / 325.02 / 322.62\n1968-05-01 / 325.57 / 322.68\n1968-06-01 / 325.36 / 323.19\n1968-07-01 / 324.14 / 323.47\n1968-08-01 / 322.11 / 323.44\n1968-09-01 / 320.33 / 323.32\n1968-10-01 / 320.25 / 323.33\n1968-11-01 / 321.32 / 323.25\n1968-12-01 / 322.89 / 323.68\n1969-01-01 / 324.00 / 323.96\n1969-02-01 / 324.41 / 323.77\n1969-03-01 / 325.63 / 324.32\n1969-04-01 / 326.66 / 324.28\n1969-05-01 / 327.38 / 324.48\n1969-06-01 / 326.71 / 324.51\n1969-07-01 / 325.88 / 325.18\n1969-08-01 / 323.66 / 324.97\n1969-09-01 / 322.38 / 325.37\n1969-10-01 / 321.78 / 324.88\n1969-11-01 / 322.85 / 324.79\n1969-12-01 / 324.12 / 324.91\n1970-01-01 / 325.06 / 325.02\n1970-02-01 / 325.98 / 325.33\n1970-03-01 / 326.93 / 325.61\n1970-04-01 / 328.13 / 325.74\n1970-05-01 / 328.08 / 325.16\n1970-06-01 / 327.67 / 325.46\n1970-07-01 / 326.34 / 325.64\n1970-08-01 / 324.69 / 326.00\n1970-09-01 / 323.10 / 326.10\n1970-10-01 / 323.06 / 326.18\n1970-11-01 / 324.01 / 325.95\n1970-12-01 / 325.13 / 325.93\n1971-01-01 / 326.17 / 326.13\n1971-02-01 / 326.68 / 326.03\n1971-03-01 / 327.17 / 325.85\n1971-04-01 / 327.79 / 325.38\n1971-05-01 / 328.93 / 326.00\n1971-06-01 / 328.57 / 326.36\n1971-07-01 / 327.36 / 326.65\n1971-08-01 / 325.43 / 326.75\n1971-09-01 / 323.36 / 326.37\n1971-10-01 / 323.56 / 326.68\n1971-11-01 / 324.80 / 326.75\n1971-12-01 / 326.01 / 326.81\n1972-01-01 / 326.77 / 326.73\n1972-02-01 / 327.63 / 326.98\n1972-03-01 / 327.75 / 326.40\n1972-04-01 / 329.72 / 327.29\n1972-05-01 / 330.07 / 327.13\n1972-06-01 / 329.09 / 326.89\n1972-07-01 / 328.04 / 327.36\n1972-08-01 / 326.32 / 327.67\n1972-09-01 / 324.84 / 327.87\n1972-10-01 / 325.20 / 328.33\n1972-11-01 / 326.50 / 328.45\n1972-12-01 / 327.55 / 328.35\n1973-01-01 / 328.55 / 328.50\n1973-02-01 / 329.56 / 328.90\n1973-03-01 / 330.30 / 328.97\n1973-04-01 / 331.50 / 329.08\n1973-05-01 / 332.48 / 329.53\n1973-06-01 / 332.07 / 329.84\n1973-07-01 / 330.87 / 330.16\n1973-08-01 / 329.31 / 330.64\n1973-09-01 / 327.51 / 330.55\n1973-10-01 / 327.18 / 330.32\n1973-11-01 / 328.16 / 330.13\n1973-12-01 / 328.64 / 329.44\n1974-01-01 / 329.35 / 329.31\n1974-02-01 / 330.71 / 330.05\n1974-03-01 / 331.48 / 330.14\n1974-04-01 / 332.65 / 330.22\n1974-05-01 / 333.09 / 330.13\n1974-06-01 / 332.25 / 330.01\n1974-07-01 / 331.18 / 330.46\n1974-08-01 / 329.39 / 330.73\n1974-09-01 / 327.43 / 330.48\n1974-10-01 / 327.37 / 330.52\n1974-11-01 / 328.46 / 330.43\n1974-12-01 / 329.57 / 330.38\n1975-01-01 / 330.40 / 330.36\n1975-02-01 / 331.40 / 330.74\n1975-03-01 / 332.04 / 330.69\n1975-04-01 / 333.31 / 330.87\n1975-05-01 / 333.97 / 331.00\n1975-06-01 / 333.60 / 331.36\n1975-07-01 / 331.90 / 331.19\n1975-08-01 / 330.06 / 331.39\n1975-09-01 / 328.56 / 331.61\n1975-10-01 / 328.34 / 331.50\n1975-11-01 / 329.49 / 331.47\n1975-12-01 / 330.76 / 331.57\n1976-01-01 / 331.75 / 331.70\n1976-02-01 / 332.57 / 331.90\n1976-03-01 / 333.50 / 332.12\n1976-04-01 / 334.58 / 332.12\n1976-05-01 / 334.88 / 331.90\n1976-06-01 / 334.33 / 332.10\n1976-07-01 / 333.05 / 332.36\n1976-08-01 / 330.94 / 332.31\n1976-09-01 / 329.30 / 332.38\n1976-10-01 / 328.94 / 332.11\n1976-11-01 / 330.31 / 332.29\n1976-12-01 / 331.68 / 332.49\n1977-01-01 / 332.93 / 332.88\n1977-02-01 / 333.42 / 332.75\n1977-03-01 / 334.70 / 333.35\n1977-04-01 / 336.07 / 333.62\n1977-05-01 / 336.75 / 333.76\n1977-06-01 / 336.27 / 334.01\n1977-07-01 / 334.92 / 334.20\n1977-08-01 / 332.75 / 334.10\n1977-09-01 / 331.59 / 334.67\n1977-10-01 / 331.16 / 334.35\n1977-11-01 / 332.40 / 334.40\n1977-12-01 / 333.85 / 334.66\n1978-01-01 / 334.97 / 334.93\n1978-02-01 / 335.39 / 334.72\n1978-03-01 / 336.64 / 335.28\n1978-04-01 / 337.76 / 335.30\n1978-05-01 / 338.01 / 335.02\n1978-06-01 / 337.90 / 335.63\n1978-07-01 / 336.54 / 335.82\n1978-08-01 / 334.68 / 336.03\n1978-09-01 / 332.76 / 335.85\n1978-10-01 / 332.55 / 335.74\n1978-11-01 / 333.92 / 335.92\n1978-12-01 / 334.95 / 335.77\n1979-01-01 / 336.23 / 336.18\n1979-02-01 / 336.76 / 336.09\n1979-03-01 / 337.96 / 336.60\n1979-04-01 / 338.88 / 336.41\n1979-05-01 / 339.47 / 336.47\n1979-06-01 / 339.29 / 337.01\n1979-07-01 / 337.73 / 337.01\n1979-08-01 / 336.09 / 337.44\n1979-09-01 / 333.92 / 337.01\n1979-10-01 / 333.86 / 337.07\n1979-11-01 / 335.29 / 337.30\n1979-12-01 / 336.73 / 337.55\n1980-01-01 / 338.01 / 337.97\n1980-02-01 / 338.36 / 337.69\n1980-03-01 / 340.07 / 338.68\n1980-04-01 / 340.76 / 338.26\n1980-05-01 / 341.47 / 338.45\n1980-06-01 / 341.17 / 338.91\n1980-07-01 / 339.56 / 338.86\n1980-08-01 / 337.60 / 338.99\n1980-09-01 / 335.88 / 339.00\n1980-10-01 / 336.02 / 339.23\n1980-11-01 / 337.10 / 339.11\n1980-12-01 / 338.21 / 339.03\n1981-01-01 / 339.24 / 339.19\n1981-02-01 / 340.48 / 339.80\n1981-03-01 / 341.38 / 340.01\n1981-04-01 / 342.50 / 340.02\n1981-05-01 / 342.91 / 339.89\n1981-06-01 / 342.25 / 339.96\n1981-07-01 / 340.49 / 339.76\n1981-08-01 / 338.43 / 339.80\n1981-09-01 / 336.69 / 339.81\n1981-10-01 / 336.86 / 340.08\n1981-11-01 / 338.36 / 340.38\n1981-12-01 / 339.61 / 340.44\n1982-01-01 / 340.75 / 340.71\n1982-02-01 / 341.61 / 340.94\n1982-03-01 / 342.70 / 341.32\n1982-04-01 / 343.57 / 341.08\n1982-05-01 / 344.14 / 341.10\n1982-06-01 / 343.35 / 341.05\n1982-07-01 / 342.06 / 341.32\n1982-08-01 / 339.81 / 341.18\n1982-09-01 / 337.98 / 341.10\n1982-10-01 / 337.86 / 341.10\n1982-11-01 / 339.26 / 341.29\n1982-12-01 / 340.49 / 341.32\n1983-01-01 / 341.38 / 341.33\n1983-02-01 / 342.52 / 341.84\n1983-03-01 / 343.10 / 341.72\n1983-04-01 / 344.94 / 342.44\n1983-05-01 / 345.76 / 342.71\n1983-06-01 / 345.32 / 343.01\n1983-07-01 / 343.98 / 343.25\n1983-08-01 / 342.38 / 343.75\n1983-09-01 / 339.87 / 343.00\n1983-10-01 / 339.99 / 343.24\n1983-11-01 / 341.15 / 343.19\n1983-12-01 / 342.99 / 343.82\n1984-01-01 / 343.70 / 343.65\n1984-02-01 / 344.50 / 343.83\n1984-03-01 / 345.28 / 343.87\n1984-04-01 / 347.05 / 344.52\n1984-05-01 / 347.43 / 344.38\n1984-06-01 / 346.80 / 344.51\n1984-07-01 / 345.39 / 344.69\n1984-08-01 / 343.28 / 344.68\n1984-09-01 / 341.07 / 344.23\n1984-10-01 / 341.35 / 344.60\n1984-11-01 / 342.98 / 345.01\n1984-12-01 / 344.22 / 345.05\n1985-01-01 / 344.97 / 344.92\n1985-02-01 / 345.99 / 345.31\n1985-03-01 / 347.42 / 346.04\n1985-04-01 / 348.35 / 345.83\n1985-05-01 / 348.93 / 345.86\n1985-06-01 / 348.25 / 345.93\n1985-07-01 / 346.56 / 345.82\n1985-08-01 / 344.67 / 346.06\n1985-09-01 / 343.09 / 346.24\n1985-10-01 / 342.80 / 346.07\n1985-11-01 / 344.24 / 346.29\n1985-12-01 / 345.56 / 346.39\n1986-01-01 / 346.30 / 346.25\n1986-02-01 / 346.95 / 346.27\n1986-03-01 / 347.85 / 346.46\n1986-04-01 / 349.55 / 347.03\n1986-05-01 / 350.22 / 347.14\n1986-06-01 / 349.55 / 347.23\n1986-07-01 / 347.94 / 347.20\n1986-08-01 / 345.90 / 347.29\n1986-09-01 / 344.85 / 348.02\n1986-10-01 / 344.17 / 347.45\n1986-11-01 / 345.66 / 347.71\n1986-12-01 / 346.90 / 347.74\n1987-01-01 / 348.02 / 347.98\n1987-02-01 / 348.48 / 347.79\n1987-03-01 / 349.42 / 348.02\n1987-04-01 / 350.98 / 348.45\n1987-05-01 / 351.85 / 348.76\n1987-06-01 / 351.26 / 348.92\n1987-07-01 / 349.51 / 348.77\n1987-08-01 / 348.10 / 349.49\n1987-09-01 / 346.45 / 349.62\n1987-10-01 / 346.36 / 349.65\n1987-11-01 / 347.81 / 349.87\n1987-12-01 / 348.96 / 349.81\n1988-01-01 / 350.43 / 350.39\n1988-02-01 / 351.73 / 351.04\n1988-03-01 / 352.22 / 350.79\n1988-04-01 / 353.59 / 351.02\n1988-05-01 / 354.22 / 351.12\n1988-06-01 / 353.80 / 351.48\n1988-07-01 / 352.38 / 351.66\n1988-08-01 / 350.43 / 351.85\n1988-09-01 / 348.73 / 351.92\n1988-10-01 / 348.88 / 352.18\n1988-11-01 / 350.07 / 352.13\n1988-12-01 / 351.34 / 352.18\n1989-01-01 / 352.76 / 352.71\n1989-02-01 / 353.07 / 352.38\n1989-03-01 / 353.68 / 352.27\n1989-04-01 / 355.42 / 352.87\n1989-05-01 / 355.67 / 352.56\n1989-06-01 / 355.12 / 352.77\n1989-07-01 / 353.90 / 353.15\n1989-08-01 / 351.67 / 353.07\n1989-09-01 / 349.81 / 353.00\n1989-10-01 / 349.99 / 353.30\n1989-11-01 / 351.30 / 353.37\n1989-12-01 / 352.52 / 353.37\n1990-01-01 / 353.66 / 353.62\n1990-02-01 / 354.70 / 354.00\n1990-03-01 / 355.38 / 353.97\n1990-04-01 / 356.20 / 353.64\n1990-05-01 / 357.16 / 354.04\n1990-06-01 / 356.23 / 353.87\n1990-07-01 / 354.81 / 354.06\n1990-08-01 / 352.91 / 354.31\n1990-09-01 / 350.96 / 354.17\n1990-10-01 / 351.18 / 354.50\n1990-11-01 / 352.83 / 354.91\n1990-12-01 / 354.21 / 355.06\n1991-01-01 / 354.72 / 354.68\n1991-02-01 / 355.75 / 355.05\n1991-03-01 / 357.16 / 355.74\n1991-04-01 / 358.60 / 356.03\n1991-05-01 / 359.34 / 356.21\n1991-06-01 / 358.24 / 355.88\n1991-07-01 / 356.17 / 355.42\n1991-08-01 / 354.01 / 355.42\n1991-09-01 / 352.15 / 355.37\n1991-10-01 / 352.21 / 355.55\n1991-11-01 / 353.75 / 355.83\n1991-12-01 / 354.99 / 355.84\n1992-01-01 / 355.99 / 355.94\n1992-02-01 / 356.72 / 356.02\n1992-03-01 / 357.81 / 356.36\n1992-04-01 / 359.15 / 356.55\n1992-05-01 / 359.66 / 356.53\n1992-06-01 / 359.25 / 356.90\n1992-07-01 / 357.02 / 356.30\n1992-08-01 / 355.00 / 356.44\n1992-09-01 / 353.01 / 356.25\n1992-10-01 / 353.31 / 356.64\n1992-11-01 / 354.16 / 356.25\n1992-12-01 / 355.40 / 356.25\n1993-01-01 / 356.70 / 356.66\n1993-02-01 / 357.17 / 356.46\n1993-03-01 / 358.38 / 356.95\n1993-04-01 / 359.46 / 356.88\n1993-05-01 / 360.28 / 357.13\n1993-06-01 / 359.60 / 357.22\n1993-07-01 / 357.57 / 356.81\n1993-08-01 / 355.52 / 356.94\n1993-09-01 / 353.69 / 356.93\n1993-10-01 / 353.99 / 357.34\n1993-11-01 / 355.34 / 357.44\n1993-12-01 / 356.80 / 357.66\n1994-01-01 / 358.37 / 358.32\n1994-02-01 / 358.91 / 358.21\n1994-03-01 / 359.97 / 358.54\n1994-04-01 / 361.26 / 358.67\n1994-05-01 / 361.69 / 358.53\n1994-06-01 / 360.94 / 358.56\n1994-07-01 / 359.55 / 358.79\n1994-08-01 / 357.48 / 358.90\n1994-09-01 / 355.84 / 359.09\n1994-10-01 / 356.00 / 359.36\n1994-11-01 / 357.58 / 359.69\n1994-12-01 / 359.04 / 359.90\n1995-01-01 / 359.97 / 359.92\n1995-02-01 / 361.00 / 360.30\n1995-03-01 / 361.63 / 360.20\n1995-04-01 / 363.45 / 360.85\n1995-05-01 / 363.80 / 360.63\n1995-06-01 / 363.26 / 360.87\n1995-07-01 / 361.89 / 361.13\n1995-08-01 / 359.45 / 360.88\n1995-09-01 / 358.05 / 361.31\n1995-10-01 / 357.75 / 361.13\n1995-11-01 / 359.56 / 361.68\n1995-12-01 / 360.70 / 361.56\n1996-01-01 / 362.05 / 362.00\n1996-02-01 / 363.24 / 362.54\n1996-03-01 / 364.02 / 362.56\n1996-04-01 / 364.71 / 362.08\n1996-05-01 / 365.42 / 362.24\n1996-06-01 / 364.97 / 362.59\n1996-07-01 / 363.65 / 362.92\n1996-08-01 / 361.48 / 362.94\n1996-09-01 / 359.45 / 362.73\n1996-10-01 / 359.61 / 362.99\n1996-11-01 / 360.76 / 362.87\n1996-12-01 / 362.33 / 363.19\n1997-01-01 / 363.19 / 363.14\n1997-02-01 / 363.99 / 363.28\n1997-03-01 / 364.56 / 363.12\n1997-04-01 / 366.36 / 363.74\n1997-05-01 / 366.80 / 363.61\n1997-06-01 / 365.63 / 363.22\n1997-07-01 / 364.47 / 363.70\n1997-08-01 / 362.50 / 363.94\n1997-09-01 / 360.19 / 363.47\n1997-10-01 / 360.78 / 364.17\n1997-11-01 / 362.43 / 364.56\n1997-12-01 / 364.28 / 365.14\n1998-01-01 / 365.33 / 365.28\n1998-02-01 / 366.15 / 365.44\n1998-03-01 / 367.31 / 365.87\n1998-04-01 / 368.61 / 365.99\n1998-05-01 / 369.30 / 366.11\n1998-06-01 / 368.88 / 366.46\n1998-07-01 / 367.64 / 366.87\n1998-08-01 / 365.78 / 367.22\n1998-09-01 / 363.90 / 367.19\n1998-10-01 / 364.23 / 367.64\n1998-11-01 / 365.46 / 367.59\n1998-12-01 / 366.97 / 367.84\n1999-01-01 / 368.15 / 368.10\n1999-02-01 / 368.87 / 368.16\n1999-03-01 / 369.59 / 368.14\n1999-04-01 / 371.14 / 368.51\n1999-05-01 / 371.00 / 367.80\n1999-06-01 / 370.35 / 367.93\n1999-07-01 / 369.27 / 368.49\n1999-08-01 / 366.93 / 368.37\n1999-09-01 / 364.64 / 367.94\n1999-10-01 / 365.13 / 368.55\n1999-11-01 / 366.68 / 368.81\n1999-12-01 / 368.00 / 368.88\n2000-01-01 / 369.14 / 369.09\n2000-02-01 / 369.46 / 368.75\n2000-03-01 / 370.51 / 369.03\n2000-04-01 / 371.66 / 369.00\n2000-05-01 / 371.83 / 368.61\n2000-06-01 / 371.69 / 369.28\n2000-07-01 / 370.12 / 369.37\n2000-08-01 / 368.12 / 369.60\n2000-09-01 / 366.62 / 369.94\n2000-10-01 / 366.73 / 370.15\n2000-11-01 / 368.29 / 370.43\n2000-12-01 / 369.52 / 370.40\n2001-01-01 / 370.28 / 370.23\n2001-02-01 / 371.50 / 370.78\n2001-03-01 / 372.12 / 370.66\n2001-04-01 / 372.86 / 370.21\n2001-05-01 / 374.02 / 370.79\n2001-06-01 / 373.31 / 370.87\n2001-07-01 / 371.62 / 370.84\n2001-08-01 / 369.55 / 371.00\n2001-09-01 / 367.96 / 371.28\n2001-10-01 / 368.09 / 371.53\n2001-11-01 / 369.68 / 371.83\n2001-12-01 / 371.24 / 372.12\n2002-01-01 / 372.44 / 372.39\n2002-02-01 / 373.08 / 372.36\n2002-03-01 / 373.52 / 372.05\n2002-04-01 / 374.85 / 372.20\n2002-05-01 / 375.55 / 372.31\n2002-06-01 / 375.40 / 372.95\n2002-07-01 / 374.02 / 373.24\n2002-08-01 / 371.48 / 372.94\n2002-09-01 / 370.70 / 374.03\n2002-10-01 / 370.25 / 373.70\n2002-11-01 / 372.08 / 374.24\n2002-12-01 / 373.78 / 374.66\n2003-01-01 / 374.68 / 374.63\n2003-02-01 / 375.62 / 374.90\n2003-03-01 / 376.11 / 374.64\n2003-04-01 / 377.65 / 374.99\n2003-05-01 / 378.35 / 375.11\n2003-06-01 / 378.13 / 375.67\n2003-07-01 / 376.60 / 375.82\n2003-08-01 / 374.48 / 375.95\n2003-09-01 / 372.98 / 376.32\n2003-10-01 / 373.00 / 376.46\n2003-11-01 / 374.35 / 376.51\n2003-12-01 / 375.69 / 376.57\n2004-01-01 / 376.79 / 376.74\n2004-02-01 / 377.37 / 376.64\n2004-03-01 / 378.39 / 376.89\n2004-04-01 / 380.50 / 377.80\n2004-05-01 / 380.62 / 377.36\n2004-06-01 / 379.55 / 377.11\n2004-07-01 / 377.76 / 377.01\n2004-08-01 / 375.83 / 377.33\n2004-09-01 / 374.05 / 377.41\n2004-10-01 / 374.22 / 377.69\n2004-11-01 / 375.84 / 378.01\n2004-12-01 / 377.44 / 378.33\n2005-01-01 / 378.34 / 378.29\n2005-02-01 / 379.61 / 378.88\n2005-03-01 / 380.08 / 378.61\n2005-04-01 / 382.05 / 379.37\n2005-05-01 / 382.24 / 378.97\n2005-06-01 / 382.08 / 379.61\n2005-07-01 / 380.66 / 379.88\n2005-08-01 / 378.67 / 380.14\n2005-09-01 / 376.42 / 379.78\n2005-10-01 / 376.80 / 380.28\n2005-11-01 / 378.31 / 380.49\n2005-12-01 / 379.96 / 380.85\n2006-01-01 / 381.37 / 381.32\n2006-02-01 / 382.02 / 381.29\n2006-03-01 / 382.56 / 381.08\n2006-04-01 / 384.36 / 381.68\n2006-05-01 / 384.92 / 381.65\n2006-06-01 / 384.03 / 381.55\n2006-07-01 / 382.28 / 381.49\n2006-08-01 / 380.48 / 381.95\n2006-09-01 / 378.81 / 382.18\n2006-10-01 / 379.06 / 382.55\n2006-11-01 / 380.14 / 382.33\n2006-12-01 / 381.66 / 382.55\n2007-01-01 / 382.58 / 382.53\n2007-02-01 / 383.71 / 382.98\n2007-03-01 / 384.34 / 382.85\n2007-04-01 / 386.23 / 383.53\n2007-05-01 / 386.41 / 383.13\n2007-06-01 / 385.87 / 383.39\n2007-07-01 / 384.44 / 383.65\n2007-08-01 / 381.84 / 383.32\n2007-09-01 / 380.86 / 384.25\n2007-10-01 / 380.86 / 384.36\n2007-11-01 / 382.36 / 384.55\n2007-12-01 / 383.61 / 384.51\n2008-01-01 / 385.07 / 385.02\n2008-02-01 / 385.84 / 385.11\n2008-03-01 / 385.83 / 384.31\n2008-04-01 / 386.77 / 384.04\n2008-05-01 / 388.51 / 385.22\n2008-06-01 / 388.05 / 385.58\n2008-07-01 / 386.25 / 385.49\n2008-08-01 / 384.08 / 385.60\n2008-09-01 / 383.09 / 386.49\n2008-10-01 / 382.78 / 386.28\n2008-11-01 / 384.01 / 386.20\n2008-12-01 / 385.11 / 386.01\n2009-01-01 / 386.65 / 386.61\n2009-02-01 / 387.12 / 386.39\n2009-03-01 / 388.52 / 387.02\n2009-04-01 / 389.57 / 386.86\n2009-05-01 / 390.17 / 386.86\n2009-06-01 / 389.62 / 387.12\n2009-07-01 / 388.07 / 387.27\n2009-08-01 / 386.08 / 387.57\n2009-09-01 / 384.65 / 388.06\n2009-10-01 / 384.33 / 387.85\n2009-11-01 / 386.05 / 388.25\n2009-12-01 / 387.49 / 388.39\n2010-01-01 / 388.55 / 388.50\n2010-02-01 / 390.08 / 389.34\n2010-03-01 / 391.01 / 389.51\n2010-04-01 / 392.38 / 389.66\n2010-05-01 / 393.22 / 389.90\n2010-06-01 / 392.24 / 389.73\n2010-07-01 / 390.33 / 389.53\n2010-08-01 / 388.52 / 390.01\n2010-09-01 / 386.84 / 390.25\n2010-10-01 / 387.16 / 390.70\n2010-11-01 / 388.67 / 390.88\n2010-12-01 / 389.81 / 390.71\n2011-01-01 / 391.30 / 391.25\n2011-02-01 / 391.92 / 391.18\n2011-03-01 / 392.45 / 390.95\n2011-04-01 / 393.37 / 390.64\n2011-05-01 / 394.28 / 390.96\n2011-06-01 / 393.69 / 391.18\n2011-07-01 / 392.59 / 391.79\n2011-08-01 / 390.21 / 391.71\n2011-09-01 / 389.00 / 392.43\n2011-10-01 / 388.93 / 392.48\n2011-11-01 / 390.24 / 392.46\n2011-12-01 / 391.80 / 392.71\n2012-01-01 / 393.07 / 393.02\n2012-02-01 / 393.35 / 392.61\n2012-03-01 / 394.36 / 392.82\n2012-04-01 / 396.43 / 393.66\n2012-05-01 / 396.87 / 393.53\n2012-06-01 / 395.88 / 393.38\n2012-07-01 / 394.52 / 393.75\n2012-08-01 / 392.54 / 394.07\n2012-09-01 / 391.13 / 394.57\n2012-10-01 / 391.01 / 394.56\n2012-11-01 / 392.95 / 395.17\n2012-12-01 / 394.33 / 395.24\n2013-01-01 / 395.61 / 395.55\n2013-02-01 / 396.85 / 396.10\n2013-03-01 / 397.26 / 395.74\n2013-04-01 / 398.35 / 395.60\n2013-05-01 / 399.98 / 396.63\n2013-06-01 / 398.87 / 396.34\n2013-07-01 / 397.37 / 396.56\n2013-08-01 / 395.41 / 396.92\n2013-09-01 / 393.39 / 396.84\n2013-10-01 / 393.70 / 397.26\n2013-11-01 / 395.19 / 397.43\n2013-12-01 / 396.82 / 397.73\n2014-01-01 / 397.93 / 397.87\n2014-02-01 / 398.10 / 397.35\n2014-03-01 / 399.47 / 397.95\n2014-04-01 / 401.33 / 398.57\n2014-05-01 / 401.88 / 398.52\n2014-06-01 / 401.31 / 398.77\n2014-07-01 / 399.07 / 398.26\n2014-08-01 / 397.21 / 398.72\n2014-09-01 / 395.40 / 398.86\n2014-10-01 / 395.65 / 399.23\n2014-11-01 / 397.23 / 399.46\n2014-12-01 / 398.79 / 399.70\n2015-01-01 / 399.85 / 399.80\n2015-02-01 / 400.31 / 399.56\n2015-03-01 / 401.51 / 399.99\n2015-04-01 / 403.45 / 400.69\n2015-05-01 / 404.10 / 400.74\n2015-06-01 / 402.88 / 400.33\n2015-07-01 / 401.61 / 400.80\n2015-08-01 / 399.00 / 400.51\n2015-09-01 / 397.50 / 400.96\n2015-10-01 / 398.28 / 401.87\n2015-11-01 / 400.24 / 402.48\n2015-12-01 / 401.89 / 402.81\n2016-01-01 / 402.65 / 402.60\n2016-02-01 / 404.16 / 403.41\n2016-03-01 / 404.85 / 403.30\n2016-04-01 / 407.57 / 404.77\n2016-05-01 / 407.66 / 404.28\n2016-06-01 / 407.00 / 404.48\n2016-07-01 / 404.50 / 403.72\n2016-08-01 / 402.24 / 403.79\n2016-09-01 / 401.01 / 404.50\n2016-10-01 / 401.50 / 405.09\n2016-11-01 / 403.64 / 405.88\n2016-12-01 / 404.55 / 405.47\n2017-01-01 / 406.07 / 406.02\n2017-02-01 / 406.64 / 405.89\n2017-03-01 / 407.05 / 405.52\n2017-04-01 / 408.95 / 406.17\n2017-05-01 / 409.91 / 406.52\n2017-06-01 / 409.12 / 406.56\n2017-07-01 / 407.20 / 406.38\n2017-08-01 / 405.24 / 406.76\n2017-09-01 / 403.27 / 406.75\n2017-10-01 / 403.64 / 407.25\n2017-11-01 / 405.17 / 407.43\n2017-12-01 / 406.75 / 407.68\n2018-01-01 / 408.05 / 408.00\n2018-02-01 / 408.34 / 407.59\n2018-03-01 / 409.25 / 407.72\n2018-04-01 / 410.30 / 407.52\n2018-05-01 / 411.30 / 407.91\n2018-06-01 / 410.88 / 408.31\n2018-07-01 / 408.90 / 408.08\n2018-08-01 / 407.10 / 408.63\n2018-09-01 / 405.59 / 409.08\n2018-10-01 / 405.99 / 409.61\n2018-11-01 / 408.12 / 410.38\n2018-12-01 / 409.23 / 410.15\n2019-01-01 / 410.92 / 410.87\n2019-02-01 / 411.66 / 410.90\n2019-03-01 / 412.00 / 410.46\n2019-04-01 / 413.52 / 410.72\n2019-05-01 / 414.83 / 411.42\n2019-06-01 / 413.96 / 411.38\n2019-07-01 / 411.85 / 411.03\n2019-08-01 / 410.08 / 411.62\n2019-09-01 / 408.55 / 412.06\n2019-10-01 / 408.43 / 412.06\n2019-11-01 / 410.29 / 412.56\n2019-12-01 / 411.85 / 412.78\n2020-01-01 / 413.37 / 413.32\n2020-02-01 / 414.09 / 413.33\n2020-03-01 / 414.51 / 412.94\n2020-04-01 / 416.18 / 413.35\n"

So we can specify the separator option when loading the data to create our properly-formed dataset:

(tc/dataset "data/tabular_data/co2_over_time.txt" {:separator "/"})

data/tabular_data/co2_over_time.txt [741 3]:

Date CO2 adjusted CO2
1958-03-01 315.70 314.44
2020-03-01 414.51 412.94
2020-04-01 416.18 413.35

Spreadsheets

Excel

.xls

Loading .xls files requires the tech.v3.libs.poi namespace to be loaded. It is not included by default by tech.ml.dataset because poi has a hard dependency on log4j2 which the core team at tech.ml.dataset (upon which tablecloth is built) did not want to impose on all users by default.

Depending on your project’s dependencies, you may get an error the first time you try to load the tech.v3.libs.poi namespace saying something like “Execution error (ClassNotFoundException) org.apache.poi.ss.usermodel.Workbook”. We need to explicitly require the dependencies for working with .xls files, adding them to our deps.edn file:

1 org.apache.poi/poi {:mvn/version "5.2.5"}
2 org.apache.poi/poi-ooxml {:mvn/version "5.2.5"}
1
search for the latest org.apache.poi/poi version here
2
search for the latest org.apache.poi/poi-ooxml version here
Note

It is important that the poi and poi-ooxml dependencies both have the same version. Mixing versions is not supported and will fail in unpredictable ways.

You may also start seeing messages in your REPL along the lines of “SLF4J: Defaulting to no-operation (NOP) logger implementation” and/or “ERROR StatusLogger Log4j2 could not find a logging implementation” now, too, unless you already have log4j configured. Due to the dependency mentioned above, you need to make sure your project explicitly specifies a logger dependency. These messages are harmless, but if you want to get rid of them you can add the two missing logging libraries to your deps.edn file:

1org.apache.logging.log4j/log4j-core {:mvn/version "2.23.1"}
2org.slf4j/slf4j-simple {:mvn/version "2.0.13"}
1
search for the latest org.apache.logging.log4j/log4j-core version here
2
search for the latest org.slf4j/slf4j-simple version here

Now we should finally be able to load the tech.v3.libs.poi namespace without any issues:

(require '[tech.v3.libs.poi :as xls])

And now our excel spreadsheet should load. If there’s a single sheet in the workbook, tablecloth will just work.

(tc/dataset "data/tabular_data/example_XLS.xls")

data/tabular_data/example_XLS.xls [50 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

With multiple sheets we get an error:

(tc/dataset "data/tabular_data/example_multiple_sheets_XLS.xls")

_unnamed [1 2]:

:\(value | :\)error
data/tabular_data/example_multiple_sheets_XLS.xls Multiple (3) datasets found in file

So we can load the file as a sequence of datasets and work with them from there. We can load them all using xl/workbook->datasets.

(def xls-sheets
  (xls/workbook->datasets "data/tabular_data/example_multiple_sheets_XLS.xls"))

There are also options for configuring how column names are rendered and how values are parsed. They are a subset of the arguments for creating a new dataset, documented here.

Now we can work with the sequence of datasets like any other Clojure seq:

(map tc/dataset-name xls-sheets)
("Sheet1" "Sheet2" "Sheet3")

Or get a single one to work on:

(first xls-sheets)

Sheet1 [50 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

If, for some reason, you know you don’t want to load all the sheets as datasets pre-emptively, for example if they’re very large and you only want to work with one of them, you can load the workbook itself, which allows you to iterate through the sheets without parsing them. input->workbook returns an implementation of tech.v3.dataset/Spreadsheet$Workbook:

(def xls-workbook
  (xls/input->workbook "data/tabular_data/example_multiple_sheets_XLS.xls"))

The easiest way to work with this sequence of workbooks is to convert it to a Clojure seq:

(nth (iterator-seq (.iterator xls-workbook)) 2)
#object[tech.v3.libs.poi$wrap_sheet$reify__33261 0x5aa6bb7c "tech.v3.libs.poi$wrap_sheet$reify__33261@5aa6bb7c"]

From here, we can reify a given sheet by calling tech.v3.dataset.io.spreadsheet/sheet->dataset:

(require '[tech.v3.dataset.io.spreadsheet :as ssheet])
(-> xls-workbook
    .iterator
    iterator-seq
    (nth 2)
    (ssheet/sheet->dataset {}))

Sheet3 [34 8]:

Index First Name Last Name Gender Country Age Date Id
17.0 Shavon Benito Female France 39.0 15/10/2017 3579.0
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

.xlsx

Tablecloth supports .xlsx files only if the underlying Java library for working with this file format is added as a dependency and required. It’s not required by default because the core team at tech.ml.dataset(upon which tablecloth is built) did not want to impose it and all of its dependencies on all users by default. If you want to work with excel files, you can add the dependency to your deps.edn file:

org.dhatim/fastexcel-reader {:mvn/version "0.16.4" :exclusions [org.apache.poi/poi-ooxml]}

and then we can require the library:

(require '[tech.v3.libs.fastexcel :as xlsx])

And now our excel spreadsheet should load. These behave the same way as .xls files. For completeness, specific examples are given below.

If there’s a single sheet, tablecloth will just work:

(tc/dataset "data/tabular_data/example_XLSX.xlsx")

data/tabular_data/example_XLSX.xlsx [50 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

With multiple sheets it throws an error:

(tc/dataset "data/tabular_data/example_multiple_sheets_XLSX.xlsx")

_unnamed [1 2]:

:\(value | :\)error
data/tabular_data/example_multiple_sheets_XLSX.xlsx Multiple (3) datasets found in file

So we can load the file as a sequence of datasets. The same options are supported for configuring how the data gets loaded documented here:

(xlsx/workbook->datasets "data/tabular_data/example_multiple_sheets_XLSX.xlsx")

[

Sheet1 [50 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
... ... ... ... ... ... ... ...
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

Sheet2 [31 8]:

Index First Name Last Name Gender Country Age Date Id
20.0 Teresa Strawn Female France 46.0 21/05/2015 3569.0
... ... ... ... ... ... ... ...
49.0 Jeromy Danz Male United States 39.0 15/10/2017 3265.0
50.0 Rasheeda Alkire Female United States 29.0 16/08/2016 6125.0

Sheet3 [30 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
... ... ... ... ... ... ... ...
29.0 Garth Gangi Male United States 41.0 16/08/2016 3256.0
30.0 Carla Trumbull Female Great Britain 28.0 21/05/2015 3264.0

]

If you don’t want to pre-emptively create datasets for all of your sheets (for example if they’re very large), you can load them lazily with xlsx/input->workbook:

(def xlsx-workbook
  (xlsx/input->workbook "data/tabular_data/example_multiple_sheets_XLSX.xlsx"))

And now work with this workbook as a lazy sequence of un-reified sheets:

(-> xlsx-workbook
    .iterator
    iterator-seq
    (nth 2)
    (ssheet/sheet->dataset {}))

Sheet3 [30 8]:

Index First Name Last Name Gender Country Age Date Id
1.0 Dulce Abril Female United States 32.0 15/10/2017 1562.0
29.0 Garth Gangi Male United States 41.0 16/08/2016 3256.0
30.0 Carla Trumbull Female Great Britain 28.0 21/05/2015 3264.0

Google Sheets

TODO

source: src/book/part_1_data_import/1_tabular_data.clj