Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LlamaIndexTS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
LlamaIndexTS
Commits
67c8b653
Commit
67c8b653
authored
1 year ago
by
swk777
Committed by
Yi Ding
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add papa config
parent
efc0e2e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/core/src/readers/CSVReader.ts
+5
-5
5 additions, 5 deletions
packages/core/src/readers/CSVReader.ts
with
5 additions
and
5 deletions
packages/core/src/readers/CSVReader.ts
+
5
−
5
View file @
67c8b653
import
{
DEFAULT_FS
,
GenericFileSystem
}
from
"
../storage/FileSystem
"
;
import
Papa
,
{
Parse
Local
Config
}
from
"
papaparse
"
;
import
Papa
,
{
ParseConfig
}
from
"
papaparse
"
;
import
{
BaseReader
}
from
"
./base
"
;
import
{
Document
}
from
"
../Node
"
;
...
...
@@ -12,7 +12,7 @@ export class PapaCSVReader implements BaseReader {
private
concatRows
:
boolean
;
private
colJoiner
:
string
;
private
rowJoiner
:
string
;
private
papaConfig
?:
Parse
Local
Config
;
private
papaConfig
?:
ParseConfig
;
/**
* Constructs a new instance of the class.
...
...
@@ -24,7 +24,7 @@ export class PapaCSVReader implements BaseReader {
concatRows
:
boolean
=
true
,
colJoiner
:
string
=
"
,
"
,
rowJoiner
:
string
=
"
\n
"
,
papaConfig
?:
Parse
Local
Config
papaConfig
?:
ParseConfig
)
{
this
.
concatRows
=
concatRows
;
this
.
colJoiner
=
colJoiner
;
...
...
@@ -42,8 +42,8 @@ export class PapaCSVReader implements BaseReader {
file
:
string
,
fs
:
GenericFileSystem
=
DEFAULT_FS
):
Promise
<
Document
[]
>
{
const
fileContent
=
await
fs
.
readFile
(
file
,
"
utf-8
"
);
const
result
=
Papa
.
parse
(
fileContent
);
const
fileContent
:
string
=
await
fs
.
readFile
(
file
,
"
utf-8
"
);
const
result
=
Papa
.
parse
(
fileContent
,
this
.
papaConfig
);
const
textList
=
result
.
data
.
map
((
row
:
any
)
=>
{
// Compatible with header row mode
const
rowValues
=
Object
.
values
(
row
).
map
((
value
)
=>
String
(
value
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment