V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
youthfire
V2EX  ›  Python

Count SQLite 中某个 Column 时遇到的问题

  •  
  •   youthfire · 2019-03-07 11:48:30 +08:00 · 1229 次点击
    这是一个创建于 1870 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想要统计某个 Column 存在数值的单元格总数时发生错误。

    通过排查发现,默认情况下,单元格都是 Null,用 DB Browser 点击具体单元格,显示 Type of data currently in cell:Null. 但存在一些单元格是空的,点击显示 Type of data currently in cell:Text/Numeric (怀疑是用 Pandas 写入时造成的),但这些又不是空格。统计时,总是把这些单元格也统计为有具体数值的,导致错误。

    求教怎么让这些空的(又不是空格)的单元格变成 Null?

    1 条回复    2019-03-07 12:24:11 +08:00
    xpresslink
        1
    xpresslink  
       2019-03-07 12:24:11 +08:00   ❤️ 1
    建议楼主先把概念整明白了, 再弄。
    空字符串"",空格" ", 空值 NULL 是三个完全不同的东东。

    update tablename
    set columnname = NULL
    where columname ="" or columname =" ";
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2543 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 01:23 · PVG 09:23 · LAX 18:23 · JFK 21:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.