Platform
Resources
Pricing
Sign in
Get started
Simon Jockers
Workspace
Fork
Public
By
Simon Jockers
Edited
Sep 28, 2023
Fork of
How to use the 'Flat file' API (#rC3 example)
•
1 fork
1 star
1
Insert cell
Insert cell
Insert cell
input_file
=
{
// Source file:
// https://www.regionalstatistik.de/genesis/online?operation=download&code=61511-01-03-4-B®ionalschluessel=09162,11000,02000&zeitscheiben=10&option=ffcsv
const
fileBuffer
=
await
FileAttachment
(
"61511-01-03-4-B_flat.csv"
)
.
arrayBuffer
(
)
// Source file is encoded using ISO 8859-1 / Windows-1252:
const
windows1252
=
new
TextDecoder
(
'windows-1252'
)
return
windows1252
.
decode
(
fileBuffer
)
}
Insert cell
Insert cell
// Source file uses semicolons as delimiters and commas as decimal separators
input_data
=
aq
.
fromCSV
(
input_file
,
{
delimiter
:
';'
,
decimal
:
','
}
)
Insert cell
Insert cell
Insert cell
table
=
input_data
.
filter
(
d
=>
d
[
'2_Auspraegung_Label'
]
===
'Insgesamt'
)
.
select
(
{
'1_Auspraegung_Label'
:
'city'
,
'Zeit'
:
'year'
,
'BAU004__Durchschnittlicher_Kaufwert_je_qm__EUR'
:
'value'
}
)
Insert cell
Insert cell
Insert cell
pivoted_table
=
table
.
groupby
(
'year'
)
.
pivot
(
'city'
,
'value'
)
Insert cell
Insert cell
Insert cell
[
...
pivoted_table
]
Insert cell
vegalite
(
{
data
:
{
values
:
[
...
table
]
}
,
mark
:
"line"
,
encoding
:
{
x
:
{
field
:
"year"
}
,
y
:
{
field
:
"value"
,
type
:
"quantitative"
}
,
color
:
{
field
:
"city"
,
type
:
"nominal"
}
}
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input_file
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
input_data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
table
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
pivoted_table
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
vegalite
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML