我有一个CSV文件,我正在阅读Python,如果第一列为空,我希望程序跳过该行.我该怎么做呢?
现在我有:
with open('testdata1.csv', 'rU') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
if row[0] = null:
#?????
Run Code Online (Sandbox Code Playgroud)
我如何:1)检查CSV中的空单元格; 2)告诉读者跳过这一行?
多谢你们.
目前可以在活动下显示对象列表,但采访仍然是空的(尽管有与采访对象数量相对应的项目符号 - 只是文本没有显示)。
视图.py:
class IndexView(generic.ListView):
template_name = 'expcore/index.html'
model = Activity
context_object_name = 'activities_list'
queryset = Activity.objects.all()
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
context['interviews_list'] = Interview.objects.all()
return context
Run Code Online (Sandbox Code Playgroud)
索引.html:
<div>
<h1>Activities</h1>
<ul>
{% for activity in activities_list %}
<li><a href='/activity/{{ activity.name }}'></a></li>
{% empty %}
<li>No activities available yet.</li>
{% endfor %}
</ul>
</div>
<div>
<h1>Interviews</h1>
<ul>
{% for interview in interviews_list %}
<li><a href='/interview/{{ interview }}'>{{ interview.name }}</a></li>
{% empty %}
<li>No interviews available yet.</li>
{% endfor …Run Code Online (Sandbox Code Playgroud)