私は考古学者で、6x6 の正方形のグリッドに配置された発掘調査の結果を処理しています。各正方形は 5 mx 5 m です。
発掘調査で見つかった出土品の分布をグリッドにプロットしたいと考えています。
Excel データベースの値を 6x6 の Python/Pygame グリッドに表示したいと考えています。
誰かが私にこれを行う方法を教えてください。
Python で Excel ドキュメントを読み取る方法は知っていると思います*.csv
が、グリッドに表示できません。
データに関する編集 データ
のスニペットはリンクにあります。「分類」列の項目をグリッドに表示したいと思います。
http://i48.tinypic.com/2rdgn02.jpg
たとえば
、各正方形の「準備フレーク」の数は、数字または色/形状のいずれかであり、各正方形は列 S のグリッド正方形番号に対応しています。データベースは非常に大きくなっています。
したがって、
理想的には、プログラムを継続的に変更することなく、プログラムがデータベースを読み取って正方形を更新するようにしたいと考えています。
コードは次のようになりました。
<import csv
import os
import pygame
# the functions for display
def disp(phrase,loc,screen): # function to display phrase at loc on surface.
s = font.render(phrase, True, (255,255,255))
screen.blit(s, loc) #
def text_display_csv(filename,surface):
'''Display .csv file contents on surface'''
f = csv.reader(open("Flint catalogue v1.7 4 Feb 13 2013.csv")) # open the csv file in one line!
for row in f:
y = f.line_num # assign y as Row no.
for x,item in enumerate(row): # Get column number(x) and item
disp(item, (64*x+10,64*y+10), surface) # display item
pygame.init()
pygame.font.init()
font = pygame.font.SysFont("Courier",36) # font initialisation
screen = pygame.display.set_mode((800,600))
# the part you want to see
text = [str(i) for i in range(36)] # raw data!
text_display_csv(text,screen) # text is displayed
pygame.display.update() # screen updated
# Main loop, does nothing! :)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
break
if not running:
break
もし可能ならば。各数字が四角形の準備フレークの数を表す下図のような方法で結果を表示したいと思います。 http://i49.tinypic.com/f39hxv.png
私はどんな助けにもとても感謝しています。これが意味をなさない場合は言ってください
トム