javascript - How to properly store $ dollar values from a given excel spreadsheet into a postgresql database
问题描述
I'm trying to store dollar values in a postgresql
database. I want to later be able to filter and manipulate the data.
I'm given monthly excel spreadsheet reports and my goal is to store all that data for later use. I've downloaded the csv. However, one field is dollar amounts with a $
symbol. I believe storing as money data type is not recommended and I want to store as a numeric data type. How would I go about removing the $
from the csv? would it be better to store as text? remove $
from file before anything? Just don't know which way to go with this.
解决方案
你有一些选择。
在 Excel 中,您可以将格式从货币更改为数字,但这可能会引入舍入问题。
您可以将 CSV 原样导入临时表,并将字段作为字符串。然后,去掉 $ 符号并转换为十进制。
根据您用于导入文件的内容,大多数 ETL 工具将允许您即时转换该字段并去除 $ 符号并转换为十进制。
同样,你有选择。最好的取决于您的环境和业务规则。
推荐阅读
- python - 使用 numpy 或其他库在 python 中进行列表扩充
- go - 如何在代理后面使用 Golang 的 go mod 依赖管理?
- typescript - 用于受保护的地图访问的打字稿错误 TS2532
- c# - 怎么知道邮件已经发送,附件可以删除?
- google-apps-script - (谷歌表格脚本)清除特定单元格
- c# - 网格动态生成搜索过程中重复问题解决的算法
- javascript - 使用 ng-repeat angularjs 在表中应用行跨度
- python - 两个熊猫数据框的对称差异
- python - 安装 numpy Raspberry Pi
- rust - 如何仅为“bin”目标禁用 lints