Skip to content

Latest commit

 

History

History
82 lines (44 loc) · 4.09 KB

create_index_from_csv.md

File metadata and controls

82 lines (44 loc) · 4.09 KB

Create an Azure search index from a csv file

✨ Here we outline how to create an Azure search index from a CSV file summarizing funded award data exported from Reporter.nih.gov

1) Generate input CSV

👂 If you already have your csv ready, skip to section (2)

Our input data comes from the csv export option for Reporter.nih.gov. Navigate to reporter.nih.gov and select Advanced Search. Input your search parameters. In this case we filtered for awards made by NIGMS in FY 23. In the top right, select Export.

Select your export columns and make sure you export as a csv. In the example input data file we only selected 'Title', 'Project_ID', and 'Total_Cost', although a few other columns were also exported.

Export from Reporter

If using the UI to upload, you need to make two small edits to the csv that gets exported. First, remove the extra comma at the end of each line. Second, replace the spaces in column names in the header row. You can do this using something like Python, or just do a find/replace in a text editor.

2) Import data into Azure blob storage

👂 If you already added your data to blob storage skip to section (3)

On the home page, navigate to Storage Accounts.

Nav Storage Account

Create a new storage account if needed. Place your storage account in US East region.

Create a new container if needed, otherwise navigate to an existing container.

Create new container

Select Upload and then add your file by dropping or browsing.

Add your file

3) Index your CSV

Navigate to AI Search and create a new search.

Create new search

Click Import data

Import Data

Now fill out all the necessary parameters.

  • Data Source: Select Azure Blob Storage. New options will drop down.

  • Data source name: This can be anything, but go with something like grant-data.

  • Data to extract: Select Content and metadata.

  • Parsing mode: Select Delimited text. Check the First Line Contains Header box and leave Delimiter Character as ,.

  • Connection string: Click Choose an existing connection and navigate to your storage account and container.

  • Managed identity authentication: Leave as default.

  • Container name: Should be populated when you connect via Connection String, but otherwise just enter your container name here.

  • Blob folder: Optional, if you have a folder within the container with the file(s) you want to index, enter that path here.

  • Description: Optional.

  • If you get errors when trying to go to the next screen, make sure you don't have trailing commas in your csv, and there are not spaces in the header names. If this happens, fix those errors, re-upload to blob storage, and then try again!

    Connect to blog

Skip ahead to Customize target index.

  • Give your index a name.

  • Make Project_Number your key.

  • Make sure the expected column names are present under fields. For the columns you expect to use, select Retrievable and Searchable. If you select all the columns you will just pay for indexing you are not using.

    Customize index

Advance to Create an indexer, name your indexer, then click Submit.

Create indexer

Navigate to Indexes on the left panel and wait until your index shows as many documents as you have lines in your file. It will read 0 documents until it is finished indexing. The example 500 line csv takes about one minute.

Check index

And that is it! Now return to the tutorial notebook to run queries against this csv using GPT-4.