给我生成1000条有name genre type episodes rating members description picture 几个字段的动漫CSV数据文件
时间: 2023-12-06 13:41:30 浏览: 105
抱歉,我不能在这里直接生成文件。但是,我可以提供一个Python代码示例,您可以使用它来生成所需的CSV文件。
```python
import csv
import random
# List of possible values for each field
names = ['Naruto', 'One Piece', 'Dragon Ball', 'Attack on Titan', 'Death Note', 'Fullmetal Alchemist', 'Sailor Moon', 'Bleach', 'Hunter x Hunter', 'My Hero Academia']
genres = ['Action', 'Adventure', 'Comedy', 'Drama', 'Fantasy', 'Horror', 'Mystery', 'Romance', 'Sci-Fi', 'Thriller']
types = ['TV', 'OVA', 'Movie', 'ONA']
episodes = [12, 24, 26, 50, 100]
ratings = [8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0]
members = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]
descriptions = ['A young ninja strives to become the strongest in his village.', 'Pirates search for the ultimate treasure.', 'A boy with incredible powers fights to protect the world.', 'Humanity battles against giant man-eating Titans.', 'A student gains the power to kill anyone whose name he writes in a notebook.', 'Two brothers seek a way to restore their bodies after a failed alchemical experiment.', 'A group of teenage girls transform into magical warriors to defend the Earth.', 'A teenager gains the ability to see ghosts and becomes a Soul Reaper.', 'A boy follows in his father\'s footsteps and becomes a Hunter.', 'A boy without powers dreams of becoming a hero in a world where everyone has them.']
pictures = ['https://example.com/naruto.jpg', 'https://example.com/onepiece.jpg', 'https://example.com/dragonball.jpg', 'https://example.com/aot.jpg', 'https://example.com/deathnote.jpg', 'https://example.com/fma.jpg', 'https://example.com/sailormoon.jpg', 'https://example.com/bleach.jpg', 'https://example.com/hxh.jpg', 'https://example.com/mha.jpg']
# Generate 1000 rows of data
rows = []
for i in range(1000):
row = [random.choice(names), random.choice(genres), random.choice(types), random.choice(episodes), random.choice(ratings), random.choice(members), random.choice(descriptions), random.choice(pictures)]
rows.append(row)
# Write data to CSV file
with open('anime_data.csv', 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['name', 'genre', 'type', 'episodes', 'rating', 'members', 'description', 'picture'])
writer.writerows(rows)
```
这段代码将生成一个包含1000行的CSV文件,其中每行都包含“name”,“genre”,“type”,“episodes”,“rating”,“members”,“description”和“picture”字段的值。您可以根据需要修改列表中的值或添加/删除字段。
阅读全文