我正在寻找一个包含字符串'Total'的电子表格中的单元格,然后使用该单元格中的行来查找另一个单元格中的总值,该单元格始终是相同的单元格/列(0中的第10个单元格)基于索引).
我有以下代码,没有错误(语法),但findCell方法没有返回rowNum值:
public static void main(String[] args) throws IOException{
String fileName = "C:\\file-path\\report.xls";
String cellContent = "Total";
int rownr=0, colnr = 10;
InputStream input = new FileInputStream(fileName);
HSSFWorkbook wb = new HSSFWorkbook(input);
HSSFSheet sheet = wb.getSheetAt(0);
rownr = findRow(sheet, cellContent);
output(sheet, rownr, colnr);
finish();
}
private static void output(HSSFSheet sheet, int rownr, int colnr) {
/*
* This method displays the total value of the month
*/
HSSFRow row = sheet.getRow(rownr);
HSSFCell cell = row.getCell(colnr);
System.out.println("Your total is: " + …Run Code Online (Sandbox Code Playgroud) 我是JSF的新手,我一直在尝试存储使用ah:selectOneMenu来获取产品类别的表单中的数据.h:selectOneMenu正在从DB填充,但是,当尝试在DB中存储产品时,我收到一个错误:转换错误设置值'52'表示'null Converter'.我已经在线查看了StackOverflow和教程中的类似问题,但我仍然收到错误.
这是xhtml:
<h:selectOneMenu id="category_fk" value="#{productController.product.category_fk}"
converter="#{categoryConverter}" title="Category_fk" >
<!-- DONE: update below reference to list of available items-->
<f:selectItems value="#{productController.categoryList}" var="prodCat"
itemValue="#{prodCat}" itemLabel="#{prodCat.name}"/>
</h:selectOneMenu>
Run Code Online (Sandbox Code Playgroud)
这是产品控制器:
@Named
@RequestScoped
public class ProductController {
@EJB
private ProductEJB productEjb;
@EJB
private CategoryEJB categoryEjb;
private Product product = new Product();
private List<Product> productList = new ArrayList<Product>();
private Category category;
private List<Category> categoryList = new ArrayList<Category>();
public String doCreateProduct()
{
product = productEjb.createProduct(product);
productList = productEjb.findAllProducts();
return "listProduct";
}
@PostConstruct
public void init()
{
categoryList …Run Code Online (Sandbox Code Playgroud) 我有一个剧本,我试图从私人仓库(GIT)克隆到服务器.
我已经设置了ssh转发,当我进入服务器并尝试从同一个repo手动克隆时,它成功运行.但是,当我使用ansible将repo克隆到服务器时,它会失败并显示"Permission Denied Public Key".
这是我的剧本deploy.yml:
---
- hosts: webservers
remote_user: root
tasks:
- name: Setup Git repo
git: repo={{ git_repo }}
dest={{ app_dir }}
accept_hostkey=yes
Run Code Online (Sandbox Code Playgroud)
这就是我的ansible.cfg样子:
[ssh_args]
ssh_args = -o FowardAgent=yes
Run Code Online (Sandbox Code Playgroud)
我也能够在我的剧本中执行所有其他任务(操作,安装).
我试过了:
ansible.cfg服务器上指定sshAgentForwarding标志(与playbook相同的目录中的ansible.cfg):
ssh_args = -o ForwardingAgent = yes
become: false执行git clone运行ansible -i devops/hosts webservers -a "ssh -T git@bitbucket.org"回报:
an_ip_address | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh.",
"unreachable": true …
我正在尝试从 Web 源加载数据并将其另存为 Excel 文件,但不知道该怎么做。我该怎么办?
import requests
import pandas as pd
import xmltodict
url = "https://www.kstan.ua/sitemap.xml"
res = requests.get(url)
raw = xmltodict.parse(res.text)
data = [[r["loc"], r["lastmod"]] for r in raw["urlset"]["url"]]
print("Number of sitemaps:", len(data))
df = pd.DataFrame(data, columns=["links", "lastmod"])
Run Code Online (Sandbox Code Playgroud) 我在小型Web应用程序中使用Flask-Mail.由于应用程序很小,我使用gmail发送电子邮件.完成文档中的所有步骤后,运行应用程序以测试电子邮件功能.我继续得到一个error: [Errno 111] Connection refused.
这是我在我的电子邮件设置config.py:
MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = 'some_user@gmail.com'
MAIL_PASSWORD = 'some_password'
DEFAULT_MAIL_SENDER = 'some_user@gmail.com'
Run Code Online (Sandbox Code Playgroud)
这是我用来测试我的Flask-Mail的视图views.py:
@app.route('/', methods=['POST', 'GET'])
def index():
form = ContactForm()
if request.method == 'POST':
if form.validate():
msg = Message('New Msg - Test',
recipients=['some_user@gmail.com'])
msg.body = 'name=%s, email=%s \n Message:%s' % (form.name.data,
form.email.data,
form.message.data)
mail.send(msg)
flash('Message sent, I will contact you soon! Thanks')
return redirect(url_for('index'))
return render_template('index.html', form=form)
Run Code Online (Sandbox Code Playgroud)
我测试了是否有这样的防火墙问题:
In [2]: import …Run Code Online (Sandbox Code Playgroud) 我正在使用JPA,JSF,EJB,Derby构建应用程序.此时应用程序仍然很小.我在应用程序中有一个表单来添加新产品.将数据添加到数据库时,它会顺利进行,直到我重新启动应用程序或服务器.当我重新启动我得到的服务器或应用程序时java.lang.StackOverflowError,我仍然可以在数据库中查询产品数据库所代表的数据,但是无法创建产品.到目前为止,我在数据库中只有5个条目,但我很早就关注这种情况.
这是Ejb(为了简单起见,删除了Getter,setter和构造函数):
@Stateless
public class ProductEJB{
@PersistenceContext(unitName = "luavipuPU")
private EntityManager em;
public List<Product> findAllProducts()
{
TypedQuery<Product> query = em.createNamedQuery("findAllProducts", Product.class);
return query.getResultList();
}
public Product findProductById(int productId)
{
return em.find(Product.class, productId);
}
public Product createProduct(Product product)
{
product.setDateAdded(productCreationDate());
em.persist(product);
return product;
}
public void updateProduct(Product product)
{
em.merge(product);
}
public void deleteProduct(Product product)
{
product = em.find(Product.class, product.getProduct_id());
em.remove(em.merge(product));
}
Run Code Online (Sandbox Code Playgroud)
这是ProductController(为简单起见,删除了Getter,setter和构造函数):
@Named
@RequestScoped
public class ProductController {
@EJB
private ProductEJB productEjb;
@EJB
private CategoryEJB categoryEjb;
private Product …Run Code Online (Sandbox Code Playgroud) 尝试从我的应用程序中的表中删除或编辑用户时出现转换错误.该值将从元数据传递listUser.xhmtl到deleteUser.xhtml页面.该值正在元数据中传递,但出于某种原因,在调用delete操作时,我得到了Conversion Error setting value "someemail@somedomain.com" for 'null Converter'.用户标识是String.
这是请求userDelete.xhmtl后的url:
http://localhost:8080/lavpWebApp/user/deleteUser.xhtml?user=someemail%40somedomain.com
Run Code Online (Sandbox Code Playgroud)
这是userList.xhmtl简化:
<h:column>
<f:facet name="header">Edit</f:facet>
<h:link outcome="/user/editUser.xhtml" value="Edit User">
<f:param name="user" value="#{item.email}"/>
</h:link>
</h:column>
<h:column>
<f:facet name="header">Delete</f:facet>
<h:link outcome="/user/deleteUser.xhtml" value="Delete User">
<f:param name="user" value="#{item.email}"/>
</h:link>
</h:column>
Run Code Online (Sandbox Code Playgroud)
这是userDelete.xhtml简化:
<f:metadata>
<f:viewParam name="user" value="#{userController.user}" converter="#{userConverter}"/>
</f:metadata>
<h:body>
Do you want to delete #{userController.user.name}?
<h:form>
<h:commandButton action="#{userController.deleteUser()}"
value="Delete"/>
<h:commandButton action="#{userController.doCancelDeleteUser()}"
value ="Cancel"/>
</h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)
这是Converter类:
@ManagedBean
@FacesConverter(value="userConverter")
public class UserConverter implements Converter{
@EJB
private UserSellerEJB userEjb;
@Override
public Object …Run Code Online (Sandbox Code Playgroud) 使用pymongo我试图检索一个与之SmallUrl不同的集合中的文档null.我正在努力获得names钥匙和SmallUrl钥匙.
如果我Name只查找,查询运行正常.但是,由于我想从结果中过滤掉具有null值的文档SmallUrl,当我在查询中包含this时,查询不返回任何内容.
这是MongoDB结构:
{u'Images': {u'LargeUrl': u'http://somelink.com/images/7960/53.jpg',
u'SmallUrl': u'http://somelink.com/images/7960/41.jpg'}
u'Name': u'Some Name',
u'_id': ObjectId('512b90f157dd5920ee87049e')}
{u'Images': {u'LargeUrl': u'http://somelink.com/images/8001/53.jpg',
u'SmallUrl': null}
u'Name': u'Some Name Variation',
u'_id': ObjectId('512b90f157dd5820ee87781e')}
Run Code Online (Sandbox Code Playgroud)
这是查询的功能:
def search_title(search_title):
$ne
''' Returns a tuple with cursor (results) and the size of the cursor'''
query = {'Name': {'$regex': search_title, '$options': 'i'}, 'SmallUrl': {'$exists': True}}
projection = {'Name': 1, 'Images': 1}
try:
results = movies.find(query, projection)
except: …Run Code Online (Sandbox Code Playgroud) 我正在使用 python 中的 sqlalchemy 将一些数据从一个数据库传输到另一个数据库。我想直接快速转账。
我不知道如何使用bulk_insert_mappings()来自 SQLAlchemy的功能。(在字段方面,两个表是相同的)
这是我到目前为止所尝试的。
from sqlalchemy import create_engine, Column, Integer, String, Date
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine_old = create_engine('mysql+pymysql://<id>:<pw>@database_old.amazonaws.com:3306/schema_name_old?charset=utf8')
engine_new = create_engine('mysql+pymysql://<id>:<pw>@database_new.amazonaws.com:3306/schema_name_new?charset=utf8')
data_old = engine_before.execute('SELECT * FROM table_old')
session = sessionmaker()
session.configure(bind=engine_after)
s = session()
Run Code Online (Sandbox Code Playgroud)
如何处理“s.bulk_insert_mappings(????, data_old)”?**
有人可以帮助我吗?
谢谢你。
我为jsf创建了一个自定义转换器.getAsObject()工作正常,但getAsString()返回异常.我不确定问题出在哪里,我已经尝试以不同的方式将对象转换为字符串,但它一直在返回异常.
这是我的转换器代码:
@Named
public class ProductConverter implements Converter{
@EJB
private ProductEJB productEjb;
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if(value== null )
{
throw new ConverterException("There was an error at getAsObject()");
}
int id = Integer.parseInt(value);
return productEjb.findProductById(id);
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value == null || value.equals(""))
{
return "";
}
else
{
Integer id = ((Product)value).getProduct_id();
return String.valueOf(id);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是Product类(为简单起见,排除了Getters/Setters/equals()/ hash()):
@Entity
@NamedQueries({
@NamedQuery(name="findAllProducts", query = …Run Code Online (Sandbox Code Playgroud) 我试图用一些数据绘制箱线图,但name 'df' is not defined出现错误。下面是代码:
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import os
% matplotlib inline
# load the dataset
df = pd.read_csv("C:/Users/Kumar Chandan/Downloads/indiavix.csv")
# display 5 rows of dataset
df.head()
df=df.boxplot(column =['close'], grid = False)
Run Code Online (Sandbox Code Playgroud) python ×4
converter ×3
java-ee ×3
jsf ×3
ejb-3.0 ×2
java ×2
pandas ×2
ansible ×1
apache-poi ×1
excel ×1
flask ×1
flask-mail ×1
git ×1
javabeans ×1
jpa ×1
matplotlib ×1
metadata ×1
mongodb ×1
persistence ×1
poi-hssf ×1
pymongo ×1
python-2.7 ×1
sqlalchemy ×1
xhtml ×1