r语言读取excel文件里面代码为1的股票数据显示No data available in table
时间: 2024-03-12 15:47:01 浏览: 43
如果你使用以下代码:
```R
data <- read_excel("your_file_path.xlsx")
stock_data <- data[data$code == 1, ]
```
但是得到了"No data available in table"的错误信息,那么可能是因为Excel文件中没有代码为1的股票数据。
你可以使用以下代码来检查Excel文件中是否有代码为1的股票数据:
```R
data <- read_excel("your_file_path.xlsx")
unique(data$code) # 显示Excel文件中所有不同的代码
```
如果输出结果中没有1这个代码,那么就说明Excel文件中没有代码为1的股票数据。
相关问题
No data available in table
这个错误信息通常表示你读取的文件中没有数据。这可能是因为你指定的文件路径不正确,或者文件中确实没有数据。
首先,请确保你指定的文件路径是正确的。你可以使用 `getwd()` 命令查看当前的工作目录,并使用 `setwd()` 命令来设置正确的工作目录。你还可以使用全路径来指定文件路径,例如:
```
data <- read.table("/Users/username/Documents/data.txt", header=TRUE)
```
如果你确定路径正确但仍然无法读取数据,则可能是因为文件确实为空或者文件格式有误。你可以使用 `file.info()` 命令检查文件的大小和修改时间,以确保文件不是空文件。另外,你可以尝试使用 `read.csv()` 或者 `read.delim()` 命令来读取文件,以确保文件格式正确。
如果你还是无法读取数据,请提供更多详细信息,例如数据文件的类型和结构,以便我更好地帮助你解决问题。
java + mysql + jdbc实现图片读取并显示代码
好的,下面是使用 Java、MySQL 和 JDBC 来读取并显示图片的代码示例:
首先,需要在 MySQL 中创建一张表来存储图片,例如:
```
CREATE TABLE images (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
data LONGBLOB NOT NULL
);
```
然后,使用 JDBC 将图片插入到 MySQL 数据库中:
```
Connection conn = null;
PreparedStatement pstmt = null;
FileInputStream fis = null;
try {
// 建立数据库连接
conn = DriverManager.getConnection(DB_URL, USERNAME, PASSWORD);
// 创建 PreparedStatement
pstmt = conn.prepareStatement("INSERT INTO images (name, data) VALUES (?, ?)");
// 设置参数
pstmt.setString(1, "image.jpg");
fis = new FileInputStream("/path/to/image.jpg");
pstmt.setBinaryStream(2, fis, fis.available());
// 执行插入操作
pstmt.executeUpdate();
} catch (SQLException | IOException e) {
e.printStackTrace();
} finally {
// 关闭连接
if (pstmt != null) pstmt.close();
if (conn != null) conn.close();
if (fis != null) fis.close();
}
```
最后,使用 JDBC 从 MySQL 中读取图片并显示:
```
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
// 建立数据库连接
conn = DriverManager.getConnection(DB_URL, USERNAME, PASSWORD);
// 创建 Prepared Statement
pstmt = conn.prepareStatement("SELECT data FROM images WHERE name=?");
// 设置参数
pstmt.setString(1, "image.jpg");
// 执行查询操作
rs = pstmt.executeQuery();
if (rs.next()) {
// 获取图片数据
byte[] data = rs.getBytes("data");
// 创建图片对象
BufferedImage image = ImageIO.read(new
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)