小编smi*_*erc的帖子

将文件信息从html文件选择器输入传递给python和bokeh

我正在尝试创建一个简单的bokeh服务器应用程序,该应用程序允许用户从<input type="file">文件选择按钮加载文件。然后,该应用程序将从用户选择的文件中绘制数据。下面的代码非常简单,而且我根本不知道如何将文件选择器中的文件信息传递给python。我需要使用python处理文件I / O,而不是html或javascript。

当我bokeh serve --show example.py path/to/input_file在命令行运行时,我可以使它正常工作,但是我不希望用户每次都指定它。我需要他们能够单击按钮来“上传”文件。该应用程序在本地运行,因此没有上载到服务器或类似的东西。

有没有比这更好的方法<input type="file">

from bokeh.plotting import figure
from bokeh.layouts import layout
from bokeh.models import ColumnDataSource, Div
from bokeh.io import curdoc

desc = Div(text="""
<h1>A simple example</h1>
<input type="file">
<br />""", width=800)

# Create Column Data Source that will be used by the plot
source = ColumnDataSource(data=dict(x=[], y=[]))

p = figure(plot_height=550, plot_width=800, title="", toolbar_location='above')
p.line(x="x", y="y", source=source)

def update():
    x_data,y_data = read_file_data(input_file_name) # function to read specific …
Run Code Online (Sandbox Code Playgroud)

html python bokeh

2
推荐指数
1
解决办法
1585
查看次数

SQLite-net 中的名称表

我正在构建一个使用 SQLite 作为存储数据库的 Windows 8 C#/XAML 应用程序,我正在尝试使用 SQLite-net 语法创建多个表。

从我到目前为止的研究来看,一个表是基于一个类创建的。首先,我通过以下方式创建了一个“帐户”类:

public class Account
{
    [PrimaryKey, AutoIncrement]
    public int ID { get; set; }

    public string Name { get; set; }
    public string Type { get; set;}
}
Run Code Online (Sandbox Code Playgroud)

然后创建一个表并通过以下方式在代码中输入初始数据:

    private static readonly string _dbPath =
        Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "data.sqlite");


        using (var db = new SQLite.SQLiteConnection(_dbPath))
        {
            db.CreateTable<Account>();

            db.RunInTransaction(() =>

               db.Insert(new Account()
                    {
                        Name = "MyCheckingAccount",
                        Type = "Checking",
                    })
                    );
        }
Run Code Online (Sandbox Code Playgroud)

我想创建多个帐户表,但db.CreateTable<Account>()语法只是创建一个表,数据插入到列中,db.Insert().我看不到在哪里输入表本身的名称。

我如何创建多个表,即一个名为“BusinessAccounts”和另一个基于 Account 类的“PersonalAccounts”?

有没有办法用 SQLite-net 做到这一点?或者我是否需要以某种方式明确写出 SQLite …

c# sqlite windows-8 windows-runtime sqlite-net

1
推荐指数
1
解决办法
3682
查看次数

标签 统计

bokeh ×1

c# ×1

html ×1

python ×1

sqlite ×1

sqlite-net ×1

windows-8 ×1

windows-runtime ×1