dongshiliao7990 2012-10-19 23:37
浏览 18

数据操作PHP [关闭]

I have a csv file with data I would like the data to be filled in the empty spaces. then export to excel file or into a database for example. I would like the first column to copy the first Product A to fill the other spaces

For example

Type       Description Cost
Product A   rrrrrrrr    33.00
NEEDS FILL  ttttttttt   45.00
NEEDS FILL  eeeeeeeee   50.00
Product B   yyyyyyyyy   80.00
NEEDS FILL   qqqqqqq    90.00
NEEDS FILL  iiiiiiii    100.00

Needs to look like this

Type       Description Cost
Product A   rrrrrrrr    33.00
Product A ttttttttt     45.00
Product A  eeeeeeeee    50.00
Product B   yyyyyyyyy   80.00
Product B   qqqqqqq     90.00
Product B  iiiiiiii     100.00

The file result will be written in a file please help been scratching my head

  • 写回答

1条回答 默认 最新

  • doumen6605 2012-10-19 23:47
    关注

    Seems like you have no code, so all I can give you is outlines:

    You will need fgetcsv() to read the CSV file. You can start with the example code from the manual.

    Loop through the lines, always saving column 1 into a variable, so you will still have it on the next iteration. If column 1 in the current iteration is empty, use the saved value.

    fputcsv() can be used to create the new CSV file on the fly.

    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改