0
0
LangChainframework~10 mins

Loading CSV and Excel files in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a CSV file using LangChain's CSVLoader.

LangChain
from langchain_community.document_loaders import CSVLoader
loader = CSVLoader(file_path=[1])
docs = loader.load()
Drag options to blanks, or click blank then click option'
A"data.csv"
Bdata.csv
C'data.csv'
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the file path.
Using a variable name without defining it.
2fill in blank
medium

Complete the code to load an Excel file using LangChain's PandasExcelLoader.

LangChain
from langchain_community.document_loaders import PandasExcelLoader
loader = PandasExcelLoader(file_path=[1])
docs = loader.load()
Drag options to blanks, or click blank then click option'
A'data.csv'
Bdata.xlsx
C"data.csv"
D'data.xlsx'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a CSV file path with PandasExcelLoader.
Not using quotes around the file path.
3fill in blank
hard

Fix the error in the code to load a CSV file with LangChain's CSVLoader.

LangChain
from langchain_community.document_loaders import CSVLoader
loader = CSVLoader(file_path=[1])
docs = loader.load()
Drag options to blanks, or click blank then click option'
Adata.csv
B'data.csv'
C"data.csv"
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the file name without quotes causing a NameError.
Using double quotes inconsistently.
4fill in blank
hard

Fill both blanks to load an Excel file and specify the sheet name.

LangChain
from langchain_community.document_loaders import PandasExcelLoader
loader = PandasExcelLoader(file_path=[1], sheet=[2])
docs = loader.load()
Drag options to blanks, or click blank then click option'
A'data.xlsx'
B'Sheet1'
C'data.csv'
D'Sheet2'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a CSV file path with PandasExcelLoader.
Not specifying the sheet name as a string.
5fill in blank
hard

Fill all three blanks to load a CSV file, specify encoding, and get the documents.

LangChain
from langchain_community.document_loaders import CSVLoader
loader = CSVLoader(file_path=[1], encoding=[2])
docs = loader.[3]()
Drag options to blanks, or click blank then click option'
A'data.csv'
B'utf-8'
Cload
D'utf-16'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong encoding strings.
Calling a non-existent method instead of load().