Consider the following sample data from a data file about movies that have been added to the national film registry. The data includes the title of the movie, the year it was released, and the year it was added to the registry.

movieTitle,yearReleased,yearAdded
Chicana,1979,2021
Cooley High,1975,2021
Evergreen,1965,2021
Flowers and Trees,1932,2021
The Flying Ace,1926,2021
Cabin in the Sky,1943,2020
A Clockwork Orange,1971,2020
The Dark Knight,2008,2020
The Devil Never Sleeps,1994,2020
Freedom Riders,2010,2020
Grease,1978,2020

Download movies.txt to your computer.

Movies Dataset

Open an instance of Trinket in your browser.

Trinket

Import movies.txt using the upload button found on the far right, top corner of the trinket editor screen. It will open a dialogue window for you to navigate to the data.txt location on your computer (most likely the downloads folder). Note that only text files with the extension *.txt can be uploaded to trinket as data files.

1 answer

It seems like you're looking for guidance on how to upload a movies dataset (in a text file) to Trinket. Here are the steps you can follow to complete the process:

  1. Prepare the Data File:

    • Make sure that your data is formatted correctly in a text file named movies.txt. Based on the data you've shared, the content of movies.txt should look like this:
      movieTitle,yearReleased,yearAdded
      Chicana,1979,2021
      Cooley High,1975,2021
      Evergreen,1965,2021
      Flowers and Trees,1932,2021
      The Flying Ace,1926,2021
      Cabin in the Sky,1943,2020
      A Clockwork Orange,1971,2020
      The Dark Knight,2008,2020
      The Devil Never Sleeps,1994,2020
      Freedom Riders,2010,2020
      Grease,1978,2020
      
  2. Open Trinket:

    • Go to the Trinket website and create a new trinket (you may need to sign in or create an account if you haven't already).
  3. Upload the Data File:

    • In the Trinket editor interface, look for the upload button, which is typically located in the upper right corner of the screen.
    • Clicking on the upload button should open a file dialog. Navigate to the location on your computer where you saved movies.txt (likely in your Downloads folder).
    • Select movies.txt and click “Open” or “Upload”.
  4. Access the Data:

    • Once the file is uploaded, you can access it in your Trinket code. Depending on what you want to achieve, you may use Python to read this data.
    • For example, you can read the contents of the file with the following code:
      import csv
      
      with open('movies.txt', 'r') as file:
          reader = csv.DictReader(file)
          movies = list(reader)
      
      # Example: Print all movie titles
      for movie in movies:
          print(movie['movieTitle'])
      
  5. Manipulate or Analyze Data:

    • Now that you have loaded the data, you can proceed to manipulate or analyze it based on your project's requirements.

If you follow these steps, you should be able to successfully upload your movies dataset to Trinket and begin working with it! If you encounter any issues, please let me know, and I'll be happy to assist further.